python按照指定字符串打印出这个字符串的后面几行中的特定字符串开头的行。
比如我有一个文件:a.txt,内容如下:[test1]comment=Thisistestpath=/test1/testvalidusers=testwritelist...
比如我有一个文件:a.txt,内容如下:
[test1]
comment = This is test
path = /test1/test
valid users = test
write list = test
admin users = test
browseable = yes
public = no
[test]
comment = This is test
path = /test1/test
valid users = test1
write list = test1
admin users = test1
browseable = yes
public = no
怎么样按照[test] 这个字符串打印出path = /test1/test 这一行,不能按行号来打印,因为可能有多段,求大神指导。 展开
[test1]
comment = This is test
path = /test1/test
valid users = test
write list = test
admin users = test
browseable = yes
public = no
[test]
comment = This is test
path = /test1/test
valid users = test1
write list = test1
admin users = test1
browseable = yes
public = no
怎么样按照[test] 这个字符串打印出path = /test1/test 这一行,不能按行号来打印,因为可能有多段,求大神指导。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询