Python---- query memory address, small data pool, encoding

#id Query memory address. 
name='alex'
print(id(name))
name1='alex'
name2='alex'
print(name1==name2)
# =Assignment operation==Compare the same value
#isThe memory address is the same #Small

data pool. Int str is within a certain range, if the two values ​​are the same, in order to save memory, share a memory address.

# str 1. If there are non-letter elements, it is not a small data pool.
# int -5~~256
# 2. A single letter *int (21) exists in a small data pool.
#The rest of the types do not exist
# Encoding
# with open('The first exam--Li Jinchao.py',encoding='utf-8')as f1:
# print(f1.read(),type(f1. read()))
name='alex'
name1=b'alex'
print(name,type(name))

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325365455&siteId=291194637