本文整理汇总了Python中cjh.cli.Cli.input方法的典型用法代码示例。如果您正苦于以下问题:Python Cli.input方法的具体用法?Python Cli.input怎么用?Python Cli.input使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cjh.cli.Cli
的用法示例。
在下文中一共展示了Cli.input方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import input [as 别名]
def __init__(self, sgf_str='', skin='unicode1.json'):
# Parent constructor
super(GoGame, self).__init__()
# Declare a new dictionary
self.header_dict = {}
# If an sgf string is given...
if len(sgf_str) > 0:
# Split it up into units
self.units = sgf_str.split(';')
# Get the header string
self.units = self.units[1:]
self.header_str = self.units[0]
# Get the list of moves and
self.moves = self.units[1:]
# Strip off any whitespace
self.moves = [move.strip() for move in self.moves]
# Convert the header information to a dictionary
self.head_list = self.header_str.split(']')[:-1]
for unit in self.head_list:
l = unit.split('[')
l = [i.strip() for i in l]
self.header_dict.update({l[0]:l[1]})
self.size = eval(self.header_dict['SZ']) #there is a better way i think
# Convert the sgf representations to Turn objects
for i, v in enumerate(self.moves):
if self.moves[i][0] == 'B': colour = 'black'
elif self.moves[i][0] == 'W': colour = 'white'
address = (self.moves[i][2].upper(), self.size - (ord(self.moves[i][3]) - 97))
self.moves[i] = Turn(colour, address, self.moves[i][5:])
else:
# If this is a new game, there will be no header. So let's make one.
black_player = Cli.input("Black player's name: ")
white_player = Cli.input("White player's name: ")
self.header_dict.update({'SZ': 19, 'PW': white_player, 'PB': black_player, 'KM': 6.5, 'GM':1})
示例2: main
# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import input [as 别名]
def main():
"""
Get input from either command line args or from stdin, and echo it
back to stdout.
"""
text = ""
Cli()
if len(sys.argv[1:]) > 0:
for arg in sys.argv[1:]:
text = text + arg + ' '
print((text.rstrip())) # pylint: disable=C0325
else:
try:
while True:
print((Cli.input())) # pylint: disable=C0325
except EOFError:
pass
示例3: main
# 需要导入模块: from cjh.cli import Cli [as 别名]
# 或者: from cjh.cli.Cli import input [as 别名]
def main():
"""
Get stdin, echo translation to stdout.
"""
Cli.clear()
while True:
words = [word.strip(".").strip().lower() for word in Cli.input().split()]
if words == [":get-list"]:
list_ = [w.encode("ascii") for w in list(TRANSLATE_KEY.keys())]
print("\n{}".format(sorted(list_, key=str.lower))) # pylint: disable=C0325
continue
output = ""
for word in words:
output += TRANSLATE_KEY[word] + " "
print("{}.\n".format(output.encode("utf-8").capitalize().strip())) # pylint: disable=C0325