#!/usr/bin/python3
import os
import sys
result = os.popen('find . -name "*.sdf*"')## not os.system
res = result.read()
print(res)
res_split = res.splitlines() ## split with '\n'
for line in res_split :
print("%s\n" % (line))
line_split = line.split('.')
if 'half_base' in line:
continue
else :
if line_split[-1] == 'gz' :
os.system("gzip -d %s" % (line))
line_no_gz = '.'.join(line_split[0:-1])
else :
line_no_gz = line
os.system(r'sed -i "s/\
/0/g" %s' % (line_no_gz))
os.system("gzip %s" % (line_no_gz))
以上代码给出:
1.如何调用system cmd
2.system cmd有参数如何处理
3.如何get system的返回值
4.有环境变量符号$如何替换