• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python ucb.interact函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python ucl.load函数代码示例发布时间:2022-05-27
下一篇:
Python grid.GridUtil类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap