我得到了下面的代碼,但是在輸出(txt文件)的時候,它不會返回一個值,只是一個None
但是當我將它保存到一個txt文件時發生,當我只是運行它的程序時顯示我想要的值。Python問題輸出。字符串操作
archi2=open('googletabla.txt', 'w')
nicCoor=open("C:\Users\SistBa\PycharmProjects\seguropais\SeguroPais\NIC.txt", "r")
coorNiclines=nicCoor.readlines()
poly = []
for NicaLines0 in coorNiclines: #leyendo las coordenadas de Nicaragua
if(len(NicaLines0))>5:
NicLines=re.sub(r'99.000', '',str(NicaLines0))
NicLines1=re.sub(r' 0.000', '',str(NicLines))
if NicLines1.isspace()==False :
line = ','.join(NicLines1.split())
lista=str(poly.extend(zip(*[iter(map(float, line.split(',')))]*2)))
archi2.write(lista+'\n')
print poly
archi2.close()
我對Python的輸出是:
C:\Python27\python.exe C:/Users/SistBa/PycharmProjects/seguropais/SeguroPais/game
[(14.993, -83.152), (14.959, -83.172), (14.952, -83.2), (14.891, -83.262), (14.762, -83.31), (14.633, -83.283), (14.456, -83.221), (14.333, -83.2), (14.265, -83.214), (14.122, -83.297)...]
進程退出代碼爲0完
但是在我的txt文件如下:
None
None
None
None
None
None
None
None...
請加'C部分內容:\用戶\ SistBa \ PycharmProjects \ seguropais \ SeguroPais \ NIC.txt' – 2014-09-01 16:44:16
在「lista = ...」之後使用打印語句進行調試,以查看是否有任何內容。 – bluefoggy 2014-09-01 16:49:16