startswith和endswith(以xxx开头,以xxx结尾)

startswith和endswith(以xxx开头,以xxx结尾):

注:
以.pac.gz结尾:if g.endswith('.pac.gz'):

vi a1.py

#!/usr/bin/python

import os

d = open('/log/110Hud/tjpacgms.txt','r')
for e in d.readlines():
d.close()
for root,dirs,files in os.walk(e.strip()):
for g in files:
if g.endswith('.pac.gz'):
o = open('/log/110Hud/tjpacgms3.txt','a')
o.write(os.path.join(root,g)+"\n")
o.close()

:wq

python a1.py

猜你喜欢

转载自blog.51cto.com/yangzhiming/2133022
xxx