tychxn / jd-assistant

京东抢购助手:包含登录,查询商品库存/价格,添加/清空购物车,抢购商品(下单),查询订单等功能
MIT License
5.18k stars 1.92k forks source link

报非法的十六进制 #221

Open narutoexception opened 1 year ago

narutoexception commented 1 year ago

python3 main.py Traceback (most recent call last): File "/Users/lay/python/jd-assistant-master/main.py", line 3, in from jd_assistant import Assistant File "/Users/lay/python/jd-assistant-master/jd_assistant.py", line 18, in from util import ( File "/Users/lay/python/jd-assistant-master/util.py", line 12, in from Crypto.PublicKey import RSA File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/Crypto/PublicKey/init.py", line 21, in from Crypto.Util.asn1 import (DerSequence, DerInteger, DerBitString, File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/Crypto/Util/asn1.py", line 27, in from Crypto.Util.number import long_to_bytes, bytes_to_long File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/Crypto/Util/number.py", line 399 s = pack('>I', n & 0xffffffffL) + s ^ SyntaxError: invalid hexadecimal literal

ZhouXiaoLiu commented 1 year ago

我也是这个问题,楼主目前解决了吗

ZhouXiaoLiu commented 1 year ago

这个错误是因为在代码中使用了Python 2的旧的语法,在Python 3中会导致语法错误。

在Python 2中,整数字面值后面的L用于指示长整数(long integer)。而在Python 3中,整数字面值不再需要后缀L来表示长整数。因此,在这个代码片段中,0xffffffffL应该被简化为0xffffffff。 说白了这个三方库用的py2语法,也不知道为啥标注的用的python3环境,这个项目可能老久没有维护了,要用得靠自己改了

qingyuchan commented 10 months ago

所有的Crypto删除,重新安装下pycryptodome库