【问题标题】:python standard input output [duplicate]python标准输入输出[重复]
【发布时间】:2020-03-23 16:25:49
【问题描述】:

该函数在 tempconv.py 文件中定义为

def fahr2cels(fahr) :
    cels = 5/9 * (fahr - 32)
    return cels 

还有一个名为 tempmax_cels.txt 的文本文件 这是一行数字。 我想在像

这样的 bash shell 中编写命令行
python tempconv.py < tempmax_cels.txt 

因此计算机可以接受文本文件作为标准输入。 我该如何纠正 tempconv.py 来做到这一点? (使用导入系统模块)

【问题讨论】:

    标签: python input standards


    【解决方案1】:

    这个答案提供了你问题的所有细节,比我能做的更好: https://stackoverflow.com/a/38670261/12602635

    【讨论】:

    • 如果另一个问题提供了所有详细信息,您应该将该问题标记为重复。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-11
    • 1970-01-01
    • 1970-01-01
    • 2021-12-13
    • 1970-01-01
    • 2013-09-18
    相关资源
    最近更新 更多