标签:int bre gbk 编码 aaaaaa append code 字符 aaaaa
# python2 # print() print "abc" # range() xrange()生成器 # raw_input() # python3 # print("abc") # range() # input() # = 赋值 == 比较值是否相等 is 比较内存是否相等 id(内容) # li1 = [1, 2, 3] # li2 = li1 # li2.append(‘4‘) # print(li1) # [1, 2, 3, ‘4‘] # print(id(li2), id(li1)) # 2351029514056 2351029514056 # 数字 字符串 小数据池 # 数字的范围 -5 - 256(用的同一个id) # 字符串:1.不能有特殊字符 # 2.s * 20 还是同一个地址 s * 21以后都是两个地址 # l1 = 6 # l2 = 6 # print(id(l1), id(l2)) # 1628859584 1628859584 # # l3 = 300 # l4 = 300 # print(id(l3), id(l4)) # 2269162868528 2269163121520 # s1 = "s" * 20 # s2 = "s" * 20 # print(s1 is s2) # True # # s1 = "s" * 21 # s2 = "s" * 21 # print(s1 is s2) # False # # s1 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaas" # s2 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaas" # print(s1 is s2) # # s1 = "a@" # s2 = "a@" # print(s1 is s2) # 除了数字和字符串其他的都没有小数据池 # 表现形式是将str转换成bytes类型 # 实际上是将unicode转换成utf-8 或者gbk s1 = "Break" # encode 编码,如何将str -》 bytes s11 = s1.encode("utf-8") print(s11) # b‘Break‘ s2 = "中国" s22 = s2.encode("utf-8") s222 = s2.encode("gbk") print(s22) # b‘\xe4\xb8\xad\xe5\x9b\xbd‘ print(s222) # b‘\xd6\xd0\xb9\xfa‘
标签:int bre gbk 编码 aaaaaa append code 字符 aaaaa
原文地址:https://www.cnblogs.com/breaki/p/9278960.html