1. File "C:\Users\yong_huang\AppData\Local\Programs\Python\Python37-32\lib\site-p
ackages\nordicsemi\dfu\util.py", line 69, in query_func
choice = raw_input().lower()
NameError: name 'raw_input' is not defined
----------------python 3.0修改了输入的方式:
choice = input().lower()
2. File "C:\Users\yong_huang\AppData\Local\Programs\Python\Python37-32\lib\site-p
ackages\nordicsemi\dfu\signing.py", line 79, in gen_key
sk_file.write(self.sk.to_pem())
TypeError: write() argument must be str, not bytes
----------------修改文件打开方式:
with open(filename, "w") as sk_file:
sk_file.write(self.sk.to_pem())
------>>>
with open(filename, "wb+") as sk_file:
sk_file.write(self.sk.to_pem())
本文针对Python3.x中常见的两个编程错误进行了修正说明。首先介绍了如何解决由于Python版本升级导致的输入函数名称变更问题,其次详细解释了如何正确处理文件写入时的数据类型不匹配错误。
6178





