-1
刪除\ n這個是我發現汽車的速度,當它運行它離開印刷distance(dist)
和速度之間的線如何從一個變量
我已經看過了如何刪除\n
從代碼我見過,並試圖結束,但所有這些都使得它打印出來的字dist
,而不是數量的變量:
for line in open ('data.txt','r'):
z,x,y,dist=line.rsplit(",")
print(z)
print(x)
print(y)
print(dist)
speed = int(dist)/(int(y)-int(x))
print(speed)
試試這個:http://stackoverflow.com/questions/275018/how-can-i-remove-chomp-a-newline -in-蟒蛇 –