V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
dlx093
V2EX  ›  Python

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

  •  
  •   dlx093 · 2019-06-26 10:39:47 +08:00 · 1175 次点击
    这是一个创建于 1777 天前的主题,其中的信息可能已经有所发展或是发生改变。
    奇怪的问题,一个 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 [email protected]'
    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 [email protected]
    a -S -v2000M -M5 -RR -TK -ED -EP1 -R -INUL -IBCK -Y -tn9d -zmydocument.lst e:\downloads\at2 @mydocument.lst [email protected]

    百思不得其解
    2 条回复    2019-06-28 08:59:36 +08:00
    frostming
        1
    frostming  
       2019-06-27 15:15:45 +08:00
    建议你发完问题自己看一下,这一坨让人怎么看
    1462326016
        2
    1462326016  
       2019-06-28 08:59:36 +08:00
    请善用预览功能,否则回答问题的成本太大
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3438 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 12:30 · PVG 20:30 · LAX 05:30 · JFK 08:30
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.