要替换吗 操作系统与子流程调用():-
待处理代码修改:-你知道吗
os.system('if [ -e python ]; then mv -f test.txt /someURL/ ; fi')
我试过:-你知道吗
subprocess.call('if [ -e python ]; then mv -f test.txt /someURL/ ; fi',shell=False)
subprocess.call(shlex.split('if [ -e python ]; then mv -f test.txt /someURL/ ; fi'),shell=False)
但两者都有错误案例:你知道吗
subprocess.call('if [ -e python ]; then mv -f test.txt /someURL/ ; fi',shell=False)
File "/usr/lib64/python2.7/subprocess.py", line 524, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
我认为,最好使用
python
,而不是使用任何shell
功能,因为这个问题肯定没有显示任何shell需求相关问题 更多 >
编程相关推荐