Skip to main content
 首页 » 编程设计

python之将十六进制转换为整数,即 'L' 字符

2025年05月04日10itcoder

<分区>

我有一个 64 位十六进制数,我想将它转换为无符号整数。我跑

>>> a = "ffffffff723b8640" 
>>> int(a,16) 
18446744071331087936L 

那么数字末尾的“L”是什么?

使用以下命令也无济于事

>>> int(a,16)[:-1] 
Traceback (most recent call last): 
  File "<stdin>", line 1, in <module> 
TypeError: 'long' object is unsubscriptable 
>>> int(a,16).rstrip("L") 
Traceback (most recent call last): 
  File "<stdin>", line 1, in <module> 
AttributeError: 'long' object has no attribute 'rstrip'