【问题标题】:spoj or codechef format command line input in pythonpython中的spoj或codechef格式命令行输入
【发布时间】:2013-10-17 11:13:00
【问题描述】:

我是编程新手,并试图从 spoj 或 codechef 等平台开始。 任何人都可以帮助我以这种方式获得输入

输入

输入以单行中的测试用例数量 t (t

输出

对于每个测试用例打印所有质数 p 使得 m

我知道如何拆分行并从那里提取 int,但我不知道如何提示输入 t 行数。

谢谢。

【问题讨论】:

    标签: python python-3.x


    【解决方案1】:

    你没有。它们被传递给您的程序的stdin,您只需阅读它们而无需任何提示。这些系统会自动处理您的程序,因此无需显示花哨的提示:)。

    import sys
    
    lines = sys.stdin.readlines()
    
    # parse the input:
    # number of cases
    t = int(lines[0])
    ...
    

    【讨论】:

      猜你喜欢
      • 2014-04-20
      • 1970-01-01
      • 2013-04-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-06
      • 1970-01-01
      相关资源
      最近更新 更多