gpt4 book ai didi

python - python内存如何管理字符串对象?

转载 作者:太空宇宙 更新时间:2023-11-03 14:35:58 25 4
gpt4 key购买 nike

<分区>

for count in range(5):
str1 = 'a' * count
str2 = 'a' * count
print(id(str1) == id(str2))

Output:
True
True
False
False
False

Why we are getting False, Because

str1 = 'aaa'
str2 = 'aaa'
print(id(str1) == id(str2)) # True

Anyone explain this python memory behaviour.

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com