【发布时间】:2019-04-28 22:40:15
【问题描述】:
我正在尝试制作一个简单的程序,该程序将文本文件作为输入,然后从文件中打印出五天的温度预测。我无法从分隔字符串中获取要打印的正确值。有什么想法我在这里出错了吗?我的输出附在下面。
print("File:")
f = input()
a = open(f, 'r')
b = a.read()
c = b.split(',')
a.close()
count = 1
for i in c:
print("Day {}: {}".format(count, c))
count = count + 1
【问题讨论】:
-
How to Ask。请展示这些文件的示例。
-
文件看起来像 45, 65, 70, 23, 12
-
@liam12808 粘贴文件的内容。
-
我无权访问该文件,它是我使用的在线教科书每次运行代码时生成的,但这是每个测试文件的格式
标签: python python-3.x text printing delimiter