[d]3.2.3版与2.5不一样呀,请帮忙看看,行间有空行怎么去除
[d]3.2.3版与2.5不一样呀,请帮忙看看,行间有空行如何去除?
3.2.3版与2.5不一样呀,请帮忙看看,行间有空行如何去除?
以下代码在 2.5下运行,可以打印出文本文件的内容,行间没有空行,但是在 3.2.3下,行间总有空行。
print 后面已经加上逗号了,好像在 3.2.3 中,逗号不起作用呀?
--------------------------
Double行动:
原帖分数:40
帖子加分:40
------解决方案--------------------
print(eachLine, end='')
------解决方案--------------------
print(eachLine, end=',')
print([object, ...][, sep=' '][, end='\n'][, file=sys.stdout])
Print object(s) to the stream file, separated by sep and followed by end. sep, end and file, if present, must be given as keyword arguments.
All non-keyword arguments are converted to strings like str() does and written to the stream, separated by sep and followed by end. Both sep and end must be strings; they can also be None, which means to use the default values. If no object is given, print() will just write end.
The file argument must be an object with a write(string) method; if it is not present or None, sys.stdout will be used. Output buffering is determined by file. Use file.flush() to ensure, for instance, immediate appearance on a screen.
3.2.3版与2.5不一样呀,请帮忙看看,行间有空行如何去除?
以下代码在 2.5下运行,可以打印出文本文件的内容,行间没有空行,但是在 3.2.3下,行间总有空行。
print 后面已经加上逗号了,好像在 3.2.3 中,逗号不起作用呀?
- Python code
filename=input("请输入文件名:") fobj=open(filename,'r') for eachline in fobj: print (eachline), fobj.close()
--------------------------
Double行动:
原帖分数:40
帖子加分:40
------解决方案--------------------
print(eachLine, end='')
------解决方案--------------------
print(eachLine, end=',')
print([object, ...][, sep=' '][, end='\n'][, file=sys.stdout])
Print object(s) to the stream file, separated by sep and followed by end. sep, end and file, if present, must be given as keyword arguments.
All non-keyword arguments are converted to strings like str() does and written to the stream, separated by sep and followed by end. Both sep and end must be strings; they can also be None, which means to use the default values. If no object is given, print() will just write end.
The file argument must be an object with a write(string) method; if it is not present or None, sys.stdout will be used. Output buffering is determined by file. Use file.flush() to ensure, for instance, immediate appearance on a screen.