如何忽略空行,而在使用Python中.next

2025年03月24日 05:35
有1个网友回答
网友(1):

# coding=utf-8 file = open("blank.txt","r") file2 = open("noblank.txt","w") while 1: text = file.readline() if( text == '' ): print "结束" break elif( text == '\n'): print "换行符" else: file2.write( text ) print text file.clos...