【发布时间】:2019-06-12 09:59:51
【问题描述】:
我正在尝试为文件列表执行命令外壳,所以我尝试了这段代码
import glob
import shutil
import os
def recursListPath(path, nth = 1):
list = []
for i in range (1, nth+1):
currentpath = path + (i * "/*")
for name in glob.glob(currentpath):
list.append(name)
return list
version = "SPIRIT/1685-2009"
DirPath = "D:\\all-data"
list = recursListPath(DirPath, 4)
for item in list:
if os.path.isfile(item):
fichier=open(item, encoding="mbcs")
for ligne in fichier :
if version in ligne:
print("'%s' 2009" % fichier.name)
os.system("'%s' start C:\> script.sh -file textVersionChange.tcl -w wk -log convertversion.log -args" %fichier.name "converteddir" )
fichier.close()
为每个文件启动控制台,但没有生成任何内容 如何在 os.system 的命令中间使用变量?
【问题讨论】:
-
请修正您的代码缩进。
标签: python-3.x os.system