python标准输入输出[重复]

问题描述 投票:-2回答:1

该函数在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个回答
0
投票

此答案提供了您问题的所有详细信息,比我能做的更好:https://stackoverflow.com/a/38670261/12602635

© www.soinside.com 2019 - 2024. All rights reserved.