python文件读入
1.0
2097152.0
10460353203.0
4398046511104.0
476837158203125.0
2.1936950640377856e+16
5.5854586408328403e+17
9.223372036854776e+18
1.0941898913151237e+20
文件中放的是这样一些数,我要用python把它读进来然后放到list里面,怎么读?
这个科学记数法的读入方式是怎样的?
[解决办法]
读入每行字符,用float转换即可,精度可能略有差异,严格要求一致的话试试Decimal模块
[解决办法]
f = open("f.txt")
l = []
for line in f:
l.append(line[:-1])
l = [float(i) for i in l]
[解决办法]
我刚学python
mylist = []try: file = open('e:\\python\\2.txt','r') for eachLine in file : mylist.append(eachLine) file.close()except IOError, e: print 'file open error :' ,emylist = [float(i) for i in mylist]for li in mylist: print li
[解决办法]