我在想如何根据情况停下来。停止$config1工作。 如何进入第一站!在节点$config1之后?你知道吗
def filtre(source):
fs = open(source, 'r')
while 1:
txt = fs.readline()
if txt =='':
break
else:
print txt
if txt == "$ config1\n":
raw_input("==========================>")
if txt == "!\n":
raw_input("==========================>")
fs.close()
return
txt文件
! ************************************
! * Export File: X:\test.txt
! * Created by: PC2
! * Creation Date: 10/01/2014 18:50
! * User: test
! *************************************
!
!
$ config1
MCBR:54:62:2:32:.5:x34:y637::::
MCBR:54:62:2:32:.5:x34:y637::::
MCBR:54:62:2:32:.5:x34:y637::::
MCBR:54:62:2:32:.5:x34:y637::::
!
!
$ End of file.
谢谢,这段代码很管用,:)
您将一个
if
语句嵌套在另一个语句中,我认为您不打算这样做。你知道吗Python中的“if,else if”可以写成:
或者
或者,如果您知道
condition1
和condition2
不能同时发生,那么这会做同样的事情:缩进的程度很重要。你知道吗
相关问题 更多 >
编程相关推荐