摘要: 今日主要内容 1. 小数据池, id() 小数据池针对的是: int, str, bool 在py文件中几乎所有的字符串都会缓存. id() 查看变量的内存地址 2. is和==的区别 is 比较的是内存地址 == 比较的是内容 当两个变量指向同一个对象的时候. is是True, ==也是True 阅读全文
posted @ 2018-12-03 19:33 =-=- 阅读(101) 评论(0) 推荐(0) 编辑
摘要: id()函数可以帮我们查看一个变量的内存地址 a = 10 b = 30 print(id(a)) # 1515545088 print(id(b)) # 1515545728 lst = ['周杰伦', "麻花藤"] print(id(lst)) # 166167624 print(lst) lst = [] # 创建了一个新列表 lst.append("胡辣汤") print(i... 阅读全文
posted @ 2018-12-03 19:32 =-=- 阅读(120) 评论(0) 推荐(0) 编辑
摘要: s = "我今天非常的困" # 21个utf-8 bs = s.encode("utf-8") # 把字符串转化成utf-8格式bytes # bytes不是给人看的. 给机器用的 # 14个字节 gbk # b'\xce\xd2\xbd\xf1\xcc\xec\xb7\xc7\xb3\xa3\xb5\xc4\xc0\xa7' # 21个字节 utf-8 # b'\xe6\x88\x91... 阅读全文
posted @ 2018-12-03 19:32 =-=- 阅读(160) 评论(0) 推荐(0) 编辑