奇怪的问题,一个 py 程序 A 运行正常,用另一个 py 程序 B 调用 A,运行结果就有问题。

2019-06-26 10:39:47 +08:00
 dlx093
奇怪的问题,一个 py 程序 A 运行正常,用另一个 py 程序 B 调用 A,运行结果就有问题。
两个 py 文件在不同文件夹,
程序 A 调用 winrar 备份文件,主要代码
def on_clickbakf(self):
if self.extchanged==True:
lst2file('e:\\py3\\bakfile\\mydocument.nlst',self.listView_Ext.model().stringList())
lst2file('e:\\py3\\bakfile\\mydocument2.nlsttxt',self.listView_E2.model().stringList())
if self.pathchanged==True:
lst2file('e:\\py3\\bakfile\\mydocument.lst',self.listView_Path.model().stringList())
lst2file('e:\\py3\\bakfile\\mydocument2.lsttxt',self.listView_P2.model().stringList())
#"E:\Program Files (x86)\WinRAR\WinRAR.exe" a -S -v2000M -M5 -RR -TK -ED -EP1 -R -INUL -IBCK -Y %Choice% -z%%f %%~nf @%%f -x@%%~nf.nlst -pwood753
#line='"E:\Program Files (x86)\WinRAR\WinRAR.exe" a -S -v2000M -M5 -RR -TK -ED -EP1 -R -INUL -IBCK -Y '
exe='"E:\Program Files (x86)\WinRAR\WinRAR.exe"'
params=' a -S -v2000M -M5 -RR -TK -ED -EP1 -R -INUL -IBCK -Y '
n=self.spinBox.value()
if n>0:
st=' -tn'+str(n)+'d '
params+=st
params+='-zmydocument.lst '
#文件路径
st=self.lineEditd.text()
if len(st)>0:
params+=' '+st
st=self.lineEditf.text()
if len(st)>0:
params+=st
else:
params+='mydocument'
params+=' @mydocument.lst -x@mydocument.nlst'
st=self.lineEdit_password.text()
if len(st)>0:
params+=' -p'+st
#print(params)
self.lineEdit_file.setText(exe+params)
print(exe+params)
import pyperclip
pyperclip.copy(exe+params)
#os.system(exe+params)
#win32api.ShellExecute(0, 'open', exe, params,'',1) #改行执行结果有误,可能 exe、params 不能分开调用
os.popen(exe+params) #不阻塞当前进程 ; exe+params 一起发送,结果正确
file_append_line('e:\\py3\\bakfile\\BackupList.Log',params+'\n')

两次调用的日志参数记录一样,但是结果不同,B 调用 A 时,备份的文件夹和日期参数都不对
a -S -v2000M -M5 -RR -TK -ED -EP1 -R -INUL -IBCK -Y -tn9d -zmydocument.lst e:\downloads\at1 @mydocument.lst -x@mydocument.nlst
a -S -v2000M -M5 -RR -TK -ED -EP1 -R -INUL -IBCK -Y -tn9d -zmydocument.lst e:\downloads\at2 @mydocument.lst -x@mydocument.nlst

百思不得其解
1190 次点击
所在节点    Python
2 条回复
frostming
2019-06-27 15:15:45 +08:00
建议你发完问题自己看一下,这一坨让人怎么看
1462326016
2019-06-28 08:59:36 +08:00
请善用预览功能,否则回答问题的成本太大

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/577559

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX