我正在创建一个input.txt文件来存储我的输入,同时从cmd运行我的py脚本文件。我希望它从该文件中获取输入,就像我们在c++中可以做的那样。
a.exe < input.txt
我们如何在python中做类似的事情呢?
发布于 2020-02-10 03:02:20
我希望这能帮助你处理文本文件中的python输入:
with open("File_name.txt", "r") as file:
for line in file:
#Do something with the line in the fileThis link可以帮助你。
https://stackoverflow.com/questions/60140166
复制相似问题