1. python中os.system函數可以執行export命令嗎
返回0是執行成功了,但是你的命令裡面的錯誤是無法收到的
比如os.system('aaa')返回0,表示執行了aaa這個命令
但是可能系統根本沒有aaa這個命令
如果你要獲得詳細的運行結果,建議使用popen命令,如下例子:
prog = subprocess.Popen("mysql -usanguo -psgtest -f <%s"%sqlFilePath, stdout=subprocess.PIPE, stderr=subprocess.PIPE,shell=True)
out,error= prog.communicate()
if prog.returncode:
print 'File import error'
return [False,error]