-2
如何更改下面的代碼以提示用戶輸入列號和csv文件名而不是在代碼中聲明它?提示用戶選擇文件名
#!/bin/env python
col = 2
values = []
with open('test.csv', 'r') as csv:
for line in csv.readlines():
elements = line.strip().split(',')
values.append(int(elements[col]))
csum = sum(values)
cavg = sum(values)/len(values)
print("Sum of column %d: %f" % (col, csum))
print("Avg of column %d: %f" % (col, cavg))