(1) os.system # 仅仅在一个子终端运行系统命令,而不能获取命令执行后的返回信息 system(command) -> exit_statusExecute the command (a string) in a subshell. # 如果再命令行下执行,结果直接打印出来 >>> os.system('ls') .CHM bash document media py-django video .wmv books downloads Pictures python a
python查找指定字符 #!/usr/bin/env python import sys import re f = open("log.txt", "rb") info = open("info.txt", "ab") for line in f.readlines(): if re.search(sys.argv[1], line): info.write(line) info.close() f.close() 当形参
1>python调用Shell脚本,有两种方法:os.system()和os.popen(),前者返回值是脚本的退出状态码,后者的返回值是脚本执行过程中的输出内容.>>>help(os.system)Help on built-in function system in module posix:system(...) system(command) -> exit_status Execute the command (a string) in a subshe