當前位置: 首頁>>代碼示例>>Python>>正文


Python Cli.input方法代碼示例

本文整理匯總了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})
開發者ID:hammerhorn,項目名稱:hammerhorn-jive,代碼行數:50,代碼來源:igo.py

示例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
開發者ID:hammerhorn,項目名稱:hammerhorn-jive,代碼行數:19,代碼來源:ecat.py

示例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
開發者ID:hammerhorn,項目名稱:hammerhorn-jive,代碼行數:19,代碼來源:saypyu1.py


注:本文中的cjh.cli.Cli.input方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。