0
這裏是我到目前爲止已經試過如何在Python中以列表或數組的形式讀取負數?
with open('xy.txt') as f:
next(f, None)
alist = [line.rstrip()[1:19] for line in f]
print alist[0]
with open('xy1.txt') as f:
next(f, None)
alist1 = [line.rstrip()[1:19] for line in f]
print alist1[0]
with open('yx.txt') as f:
next(f, None)
alist = [line.rstrip()[1:19] for line in f]
print alist[0]
with open('yx1.txt') as f:
next(f, None)
alist1 = [line.rstrip()[1:19] for line in f]
print alist1[0]
當我運行代碼
5.509014339324e+03
4.927809838950e+03
6.440208621086e+03
1.912637550671e+03
但yx.txt有負數
>ZYXR //74
-6.440208621086e+03 -4.758666382870e+03 -3.995858566350e+03 -4.934315690511e+03 -5.049765912718e+03
如何解決這個問題?
是的,就是這樣,現在好的工作! –