開在下面的腳本執行結束後,我收到這樣的一些錯誤:文件中子殼
filename.enc: No such file or directory
140347508795048:error:02001002:system library:fopen:No such file or directory:bss_file.c:398:fopen('filename.enc','r')
140347508795048:error:20074002:BIO routines:FILE_CTRL:system lib:bss_file.c:400:
好像POPEN試圖關閉該文件在執行結束,雖然它被刪除。
#!/usr/bin/python
import subprocess, os
infile = "filename.enc"
outfile = "filename.dec"
opensslCmd = "openssl enc -a -d -aes-256-cbc -in %s -out %s" % (infile, outfile)
subprocess.Popen(opensslCmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True)
os.remove(infile)
如何正確關閉文件?
謝謝。
謝謝。有用。 – superNobody 2011-06-03 09:11:43