我试图将一个包含数字列表的txt文件导入python。 我假设得到文件中数字的平均值和数字的标准偏差。 我的剧本是错的,有人能告诉我正确的方法吗。在
from sys import argv
script, filename = argv
txt = open(filename)
for line in txt:
total = 0
length = 0
amount = float(line)
total += amount
length = length + 1
average = total/length
print average
应该在循环之外。在
将以下语句移出循环:-
相关问题 更多 >
编程相关推荐