摘要: 可变指的是:数据类型的引用地址可变,直接在堆区数据区对原数据直接操作 不可变指的是:数据类型的应用地址不可变,需要重新创建与原数据一致的数据进行间接操作。 参考链接:https://www.cnblogs.com/Jacck/p/7790049.html 阅读全文
posted @ 2019-04-17 22:26 挺锅锅 阅读(166) 评论(0) 推荐(0) 编辑
摘要: # 1.列表的增删改查 ls = [1, 2, 3] # 查 print(ls) print(ls[1]) # 增 ls.append(0) # 末尾增 print(ls) ls.insert(1, 666) # 任意index前增 print(ls) ls.insert(len(ls), 888) 阅读全文
posted @ 2019-04-17 22:21 挺锅锅 阅读(239) 评论(0) 推荐(0) 编辑
摘要: # 1.索引取值: 列表名[index] s1 = [1, 3, 2] print(s1[0]) print(s1[-1]) # 2.列表运算: 得到的是新list s2 = [1, 2, 3] print(s2 + s2) print(s2 * 2) print(s2) # 3.list的长度 s3 = [3, 4, 1, 2, 5] print(len(s3)) # 4.切片:[s... 阅读全文
posted @ 2019-04-17 22:18 挺锅锅 阅读(223) 评论(0) 推荐(0) 编辑
摘要: # 1.定义 ls = [3, 1, 2] # 语法糖 | 笑笑语法 print(ls) ls = list([3, 1, 2]) # 本质 print(ls) # 嵌套 ls = [3, 1, [3, 2, [1]]] # 重点:list中可以存放多个值,都可以存放什么类型 - 所有类型 阅读全文
posted @ 2019-04-17 22:16 挺锅锅 阅读(1306) 评论(0) 推荐(0) 编辑
摘要: print('000123123'.find('1')) print('000123123'.rfind('1')) print('***000123123***'.lstrip('*')) print('***000123123***'.rstrip('*')) print('华丽分割线'.center(50,'=')) print('华丽分割线'.ljust(50,'=')) print('. 阅读全文
posted @ 2019-04-17 22:14 挺锅锅 阅读(802) 评论(0) 推荐(0) 编辑
摘要: # 1.索引(目标字符串的索引位置) s1 = '123abc呵呵' print(s1.index('b')) # 2.去留白(默认去两端留白,也可以去指定字符) s2 = '***好 * 的 ***' print(s2.strip('*')) # 3.计算子字符串个数 s3 = '12312312' print(s3.count('123')) # 4.判断字符串是否是数字:只能判... 阅读全文
posted @ 2019-04-17 22:12 挺锅锅 阅读(255) 评论(0) 推荐(0) 编辑
摘要: # 1.字符串的索引取值: 字符串[index]# 正向取值从0编号,反向取值从-1编号 s1 = '123abc呵呵' print(id(s1)) # 2217572683576 print(s1[0], id(s1[0])) # 2217543167200 t_s = '1' print(id(t_s)) # 2217543167200 # 取出c print(s1[5], s1[... 阅读全文
posted @ 2019-04-17 22:08 挺锅锅 阅读(213) 评论(0) 推荐(0) 编辑
摘要: # 1.定义# 需求:你是"好学生" s1 = "你是\"好学生\"" print(s1) # 可以通过引号的嵌套,使内部不同的引号在不转义的情况下直接输出 s2 = '你是"好学生"' print(s2) # 需求:你是"好学生",是'我的' s3 = """你是"好学生",是'我的'""" pr 阅读全文
posted @ 2019-04-17 22:05 挺锅锅 阅读(1190) 评论(0) 推荐(0) 编辑
摘要: # 了了解:py2中小整数用int存放,大整数用long# 1.整型 num = -1000000000000000000000000000000000000000000000000 print(num, type(num)) # 2.小数 num = 3.14 print(num, type(num)) # 3.布尔 res = True print(res, type(res), i... 阅读全文
posted @ 2019-04-17 22:03 挺锅锅 阅读(539) 评论(0) 推荐(0) 编辑
摘要: Python是如何进行内存管理-内存池机制 Pymalloc Python引用了一个内存池(memory pool)机制,即Pymalloc机制(malloc:n.分配内存),用于对小块内存的申请和释放管理 内存池(memory pool)的概念: 当创建大量消耗小内存的对象时,频繁调用new/ma 阅读全文
posted @ 2019-04-17 20:17 挺锅锅 阅读(1021) 评论(0) 推荐(1) 编辑
摘要: 用了几天的PyCharm,发现确实在编写Python代码上非常好用,但有一点体验不太好,就是代码编写时要按照PEP8代码风格编写,不然会有波浪线的警告信息。解决方法如下: 方法一:将鼠标移到提示的地方,按 Alt+Enter,选择忽略(Ignore)这个错误即好。 方法二打开:File - Sett 阅读全文
posted @ 2019-04-17 08:55 挺锅锅 阅读(250) 评论(0) 推荐(0) 编辑
摘要: 学习Python过程中,发现Python没有Switch-case,过去写C习惯用Switch/Case语句,官方文档说通过if-elif实现。所以不妨自己来实现Switch-Case功能。 方法一 通过字典实现 方法二 通过匿名函数实现 阅读全文
posted @ 2019-04-17 08:48 挺锅锅 阅读(540) 评论(0) 推荐(0) 编辑