python运行外部文件_Python3运行外部.exe文件
我使用這個(gè)函數(shù)從txt文件加載不同的東西。到目前為止,它可以在文件資源管理器中處理網(wǎng)頁和文件位置。但是,當(dāng)位置在txt文件中傳遞給它時(shí),它不運(yùn)行.exe文件。在
這是我使用的函數(shù)def Run():
while True:
try:
fr = open('AutoLoader.txt', 'r')
lines = fr.readlines()
for line in lines:
if line[0:3] == 'web':
#open in the browser
os.startfile(line[3:])
elif line[0:3] == 'loc':
cmd = line[3:]
print(cmd)
subprocess.Popen('explorer "' + cmd + '"')
else:
#open the program
run = ('r"' + line + '"')
process = subprocess.Popen(run, stdout=subprocess.PIPE)
fr.close()
break
except FileNotFoundError:
print("Program not setup")
print("running setup")
Setup()
我正在為else語句而掙扎。這是不會(huì)發(fā)生的。在
謝謝你
總結(jié)
以上是生活随笔為你收集整理的python运行外部文件_Python3运行外部.exe文件的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java代码块执行顺序_Java笔记 |
- 下一篇: python 生成001开始的序号_你知