![](/img/trans.png)
[英]Same Python command works on one computer but doesn't on another in Maya
[英]Same python script works in one computer but not in another
我在 Python 3.8(32 位)中有以下脚本:
import sys
import time
from Crypto.Cipher import AES
which_file = str(sys.argv[1])
if which_file == "license_service":
nameoffiles = "C:\\file1.txt"
else:
nameoffiles = "C:\\file2.txt"
file_names = open(nameoffiles, "r")
filenames = file_names.read()
filenames1 = filenames.split(',')
key_location = "path_to_key"
key_to_encrypt = open(key_location, "rb")
key = key_to_encrypt.read()
key_to_encrypt.close()
for x in filenames1:
file_in = open(x, "rb")
nonce, tag, ciphertext = [file_in.read(x) for x in (16, 16, -1)]
cipher = AES.new(key, AES.MODE_EAX, nonce)
data = cipher.decrypt_and_verify(ciphertext, tag)
file_in.close()
file_out = open(x, "wb")
file_out.write(data)
该脚本读取一个包含需要解密的文件路径的文件,然后解密这些文件。
问题是在一台计算机(物理机)上运行完美,永不失败,在另一台计算机(虚拟机)上输出如下错误:
回溯(最近一次调用):文件“C:\\github\\encrypt2\\decrypt.py”,第 26 行,在 file_out = open(x, "wb") 中 TypeError: coercing to Unicode: need string or buffer, int found
由于代码在一台计算机上运行正常,我不知道我能做些什么来解决这个问题,除了试图找到计算机配置之间的差异。
找不到任何区别。
解决了,vm也安装了python 2.7,卸载后将var path设置为3.8一切正常
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.