python - python标准输入输出
问题描述
该函数在 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 来做到这一点?(使用导入系统模块)
解决方案
这个答案提供了您问题的所有细节,比我能做的更好: https ://stackoverflow.com/a/38670261/12602635
推荐阅读
- python-3.6 - 从 PIL 导入 _imaging 问题,3.6 运行良好,3.7 没有运行
- orocrm - OroCRM - 如何使用 Symfony Messenger 组件
- laravel - 重构 Laravel Eloquent 查询
- solr - 在 solr 中禁用查询结果和文档缓存,只在 solr 中使用过滤器缓存?
- .net - 微服务通信安全
- ggplot2 - 在 z=0 处添加一条线到 ggplot2 热图
- javascript - TypeScript / Javascript 无法理解的数组行为
- javascript - npm 构建到两个 dist 文件夹
- python-3.x - 我找不到运行时错误的来源。实现递归解决问题
- python - 一个包含所有必要模块的程序