我试图通过说使字符串成为整数
file = open(input("Please enter the name of the file you wish to open:" ))
while True:
A = file.readline()
if(A):
array.append(int(A[0:len(A)-1]))
else:
break
print("The numbers in the file are:", A)
file.close()
我创建的文件有数字:1 -3 10 6 5 0 3 -5 20
这是错误:
ValueError: invalid literal for int() with base 10: '1 -3 10 6 5 0 3 -5 2'