标签:内存地址 code nbsp tuple python python3 put 字符 col
python 2 python 3
python 2
print print‘abc‘
range() xrange()生成器
raw_input()
python3
print‘abc‘
range()
input()
= 賦值 ==比較值是否相等 is比較,比較的是内存地址 id(内容)
li1 = [1, 2, 3] li2 = li1 li3 = li2 print(id(li1), id(li2))
數字,字符串,小數據池
數字的範圍 -5 -- 256
字符串:1.不能有特殊字符
2.s*20 還是同一個地址, s*21以後都是兩個地址
i1 = 6 i2 = 6 print(id(i1), id(i2)) i1 = 300 i2 = 300 print(id(i1), id(i2))
剩下的list dic tuple set,都不共用一個id
l1 = [1, ] l2 = [1, ] print(l1 is l2)
s = ‘alex‘ s1 = b‘alex‘ print(s, type(s)) print(s1, type(s1)) s = ‘中國‘ s1 = b‘中國‘ print(s, type(s)) print(s1, type(s1))
s1 = ‘alex‘ # encod編碼如何將str ----> bytes, () s11 = s1.encode(‘utf-8‘) s12 = s1.encode(‘gbk‘) print(s11, s12) s1 = ‘中國‘ s11 = s1.encode(‘utf-8‘) s12 = s1.encode(‘gbk‘) print(s11, s12)
标签:内存地址 code nbsp tuple python python3 put 字符 col
原文地址:https://www.cnblogs.com/yvz5414/p/10193649.html