gpt4 book ai didi

python - 如何从执行进程任务运行 py 文件?

转载 作者:太空宇宙 更新时间:2023-11-03 15:43:51 25 4
gpt4 key购买 nike

我使用的是 VS Community 2015 的 64 位 Windows。我尝试使用执行进程任务从 Visual Studio 运行 py 代码。尝试过: enter image description here

但是,它没有给我任何输出。

Py代码是:

import patoolib
import glob
import os
import csv

zipSrc="C:\\Users\\Suraj\\Documents\\Pyhton\\Python scripts\\Input.zip"
zipDst="C:\\Users\\Suraj\\Documents\\Pyhton\\Python scripts\\Zip Output"
formatSrc="C:\\Users\\Suraj\\Documents\\Pyhton\\Python scripts\\Output Format.csv"

finalOutput="C:\\Users\\Suraj\\Documents\\Pyhton\\Python scripts\\Output"

colValues=[]
widthValues=[]
sepValues=[]
widthSum=0


with open(formatSrc,'r') as forMat:
forMatReader = csv.reader(forMat)
for line in forMatReader:
colValues.append(line[1])
widthValues.append(line[0])


for i in widthValues:
widthSum += int(i)
sepValues.append(widthSum)

patoolib.extract_archive(zipSrc,outdir=zipDst)
os.chdir(zipDst)
fileList=glob.glob("*.csv")

for file in fileList:
with open(file,'r') as f, open(finalOutput+"\\"+file,'w',newline='') as f2:
fileReader = f.readlines()
writeData = csv.writer(f2)

writeData.writerow(colValues)

for line in fileReader:
start=0
temp=[]
for value in sepValues:
temp.append(line[start:value])
start = value
writeData.writerow(temp)

还尝试过,我尝试创建我的 py 文件的 exe,以便在执行进程任务中运行,但该 exe 也没有给出我想要的输出。我使用 pyinstaller 转换为 exe 。

如有任何建议,我们将不胜感激。

提前致谢

最佳答案

运行Python的目标机器首先需要在某个地方有python.exe。确认这一点后,您需要从执行进程任务中调用 python.exe 并将 .py 文件作为参数传递到其中。这将毫无问题地执行您的 python 代码。

谢谢

房车

关于python - 如何从执行进程任务运行 py 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41929392/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com