当前位置: 首页>>代码示例>>Python>>正文


Python ucb.interact函数代码示例

本文整理汇总了Python中ucb.interact函数的典型用法代码示例。如果您正苦于以下问题:Python interact函数的具体用法?Python interact怎么用?Python interact使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了interact函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: interactive_strategy

def interactive_strategy(colony):
    """A strategy that starts an interactive session and lets the user make
    changes to the colony.

    For example, one might deploy a ThrowerAnt to the first tunnel by invoking:
    colony.deploy_ant('tunnel_0_0', 'Thrower')
    """
    game_print('colony: ' + str(colony))
    msg = '<Control>-D (<Control>-Z <Enter> on Windows) completes a turn.\n'
    interact(msg)
开发者ID:doudoujay,项目名称:cs61a,代码行数:10,代码来源:ants.py

示例2: run

def run():
    interact()
开发者ID:sqwerl,项目名称:Code-Samples--D,代码行数:2,代码来源:hw5.py

示例3: play

    winner = play(always_roll(5), always_roll(6))
    if winner == 0:
        print("Player 0, who always wants to roll 5, won.")
    else:
        print("Player 1, who always wants to roll 6, won.")

'''@main
def run(*args):
    """Read in the command-line argument and calls corresponding functions.
    
    This function uses Python syntax/techniques not yet covered in this course.
    """
    import argparse
    parser = argparse.ArgumentParser(description="Play Hog")
    parser.add_argument('--take_turn_test', '-t', action='store_true')
    parser.add_argument('--play_interactively', '-p', action='store_true')
    parser.add_argument('--play_basic', '-b', action='store_true')
    parser.add_argument('--run_experiments', '-r', action='store_true')
    parser.add_argument('--final_strategy_test', '-f', action='store_true')
    args = parser.parse_args()
    for name, execute in args.__dict__.items():
        if execute:
            globals()[name]()
'''


# Add this function to interact with the code on command line (with out adding -i)
# Must be at end of code
interact()

开发者ID:sinistrum,项目名称:Hog,代码行数:29,代码来源:hog.py

示例4: main

def main():
    diff_msgs = test_comparator()
    interact()
开发者ID:ajponte,项目名称:Message_compare,代码行数:3,代码来源:tests.py

示例5: Accumulator

####TESTING####
import Accumulator
import ucb

test_accum = Accumulator("imap.gmail.com", "[email protected]", "LottaSaulsMail", 993, "INBOX") 
ids = test_accum.get_ids()
headers = test_accum.get_header_info()   
ucb.interact()
开发者ID:ajponte,项目名称:Message_compare,代码行数:8,代码来源:accumulator_tests.py

示例6: prog

def prog():
    interact()
开发者ID:bianyin102938,项目名称:61a-sp14-website,代码行数:2,代码来源:lect12.py

示例7: main

def main():
    """Main function.  Prompts user for input.  Outputs the Message-ID
       of each message in both the source and destination.  Outputs the 
       number of messages which are different between source and destination.
       Sends a formatted table with the header content of the missing messages
       to OUTPUT_FILE."""
    
    ####GET ALL MESSAGES FROM GMAIL###
   # gmail_usr_name = raw_input("Enter the gmail user name: \n")
   # gmail_passwrd = getpass.getpass("Enter the Gmail password: \n")
    print("Please wait while message IDs for Gmail are populated...")
    gmail_accumulator = Accumulator.Accumulator(GMAIL_PATH, "usr_name", "passwrd",
                                                IMAP_PORT, GMAIL_FOLDER)
    gmail_msg_ids = gmail_accumulator.get_ids()
    pprint.pprint(gmail_msg_ids)
    
    ####GET ALL MESSAGES FROM IMAP###
    #IMAP2_usr_name = raw_input("Enter the IMAP2 user name: \n")
    #IMAP2_passwrd = getpass.getpass("Enter the IMAP2 password: \n")
    print("Please wait while message IDs for IMAP are populated")
    
    IMAP2_accumulator = Accumulator.Accumulator("imap2.lbl.gov", "usr_name", "passwrd",
                                                IMAP_PORT, IMAP2_FOLDER)
    IMAP2_msg_ids = IMAP2_accumulator.get_ids()
    pprint.pprint(IMAP2_msg_ids)
    
    gmail_unique_ids = gmail_accumulator.get_unique_ids()
    ###FIND THE DIFFERENCES BETWEEN IMAP AND GMAIL.####
    compare_ids = Comparator.Comparator(IMAP2_msg_ids, gmail_unique_ids)
    diff_ids = compare_ids.compare()
    
    ###FIND THE DUPLICATE IDs FROM IMAP2.###
    
    dups = IMAP2_accumulator.get_duplicate_ids()
    dup_headers = header_info(dups, IMAP2_accumulator)
    print("{num_msgs} messages in IMAP2/{fldr}\n".format(num_msgs = IMAP2_accumulator.count_ids(), fldr = IMAP2_accumulator.folder))
    print("{num_msgs} messages in GMAIL/{fldr}\n".format(num_msgs = gmail_accumulator.count_ids(), fldr = gmail_accumulator.folder))
    
    print("-------------------------------------------------------------------------------------")
    print("There are {num} messages in IMAP2/{fldr1} which are not in Gmail/{fldr2}\n".format(num = len(diff_ids),
                                                                                            fldr1 = IMAP2_accumulator.folder,
                                                                                            fldr2 = gmail_accumulator.folder))
    print("--------------------------------------------------------------------------------------")
    pprint.pprint(diff_ids)

    print("Here is a list of the headers of each message ID which is not in Gmail:\n")
    headers = header_info(diff_ids, IMAP2_accumulator)

    ###print a table of the info of the missing messages.###
    table = prettytable.PrettyTable(["TO", "FROM", "SUBJECT"])
    table.align["TO"] = "l"
    table.padding_width = 1
    for hdr in headers:
        table.add_row(hdr)
    print(table)


    ###write the output to OUTPUT_FILE.###

    output_file = open(OUTPUT_FILE, 'w')
    output_file.write("\n")
    output_file.write("{num_msgs} messages in IMAP2/{fldr}\n".format(num_msgs = IMAP2_accumulator.count_ids(), fldr = IMAP2_accumulator.folder))
    output_file.write("{num_msgs} messages in GMAIL/{fldr}\n".format(num_msgs = gmail_accumulator.count_ids(), fldr = gmail_accumulator.folder))
    output_file.write("There are {num} messages in IMAP2/{fldr1} which are not in Gmail/{fldr2} \n".format(num = len(diff_ids),
                                                                                            fldr1 = IMAP2_accumulator.folder,
                                                                                           fldr2 = gmail_accumulator.folder))
    output_file.write("Here is a list of the headers of each message ID which is not in Gmail:\n")
    for ids in diff_ids:
        output_file.write(str(ids))
        output_file.write("\n")
    output_file.write("\n")

    ###OUUTPUT THE TABLE###

    output_file.write(str(table)) 
    output_file.write(LINE_SEPARATOR)

    output_file.close()

    ucb.interact()
开发者ID:ajponte,项目名称:Message_compare,代码行数:80,代码来源:message_compare.py

示例8: main

def main():
    interact()
开发者ID:Arvykins,项目名称:61a-sp14-website,代码行数:2,代码来源:lect11.py


注:本文中的ucb.interact函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。