python - 什么代表 Python 中 print/repr 上显示的十六进制整数?

标签 python core

在像下面这样的交互式 session 中:

>>> f=open('test.txt','w')
>>> f
<open file 'test.txt', mode 'w' at 0x6e610>

0x6e610 代表什么,我可以用 Python 中的十六进制数做什么?

最佳答案

>>> f=open('test.txt')
>>> f
<open file 'test.txt', mode 'r' at 0x10047c938>
>>> hex(id(f))
'0x10047c938'

看看id in the official documentation :

返回对象的“身份”。这是一个整数(或长整数),保证此对象在其生命周期内是唯一且不变的。两个生命周期不重叠的对象可能具有相同的 id() 值。

关于python - 什么代表 Python 中 print/repr 上显示的十六进制整数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2556799/

相关文章:

python - 使用 .unstack 迭代 Pandas 数据帧/ reshape 数据帧列表

python - 无法解析execute_script()之后的h1元素

python - pygame : trying to understand the Sprite class

python - 将几个变量 append 到 Python 中的列表

c - 在 C 中使用 fork()

python - pandas DF 中的组连接图

c - 根据代码块分段核心转储调试它在第 120 行我的链表堆栈实现有问题吗

java - 枚举作为算术运算

c# Environment.ProcessorCount 并不总是返回逻辑处理器的完整数量,为什么?

wpf - 使用 MSIX 发布 WPF Core...多个问题