Python 基础学习7 - print line

来源:互联网 发布:网络电视哪种好 编辑:程序博客网 时间:2024/06/06 03:41
  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 line1This is line2This is line3

0 0
原创粉丝点击