Python 基礎學習7 - print line

  1.  Python的print line的特別之處是默認會打印換行符:

e.g

f = open("Test.txt")
for fline in f:
    print fline

返回:
This is line1

This is line2

This is line3
注意:每行之後都有換行符
如何去掉默認的換行符呢?
加一個逗號print fline, 即可去掉每行自帶的換行符
f = open("Test.txt")
for fline in f:
    print fline,
返回:
This is line1
This is line2
This is line3



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章