摘要: # 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 挺锅锅 阅读(1020) 评论(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) 编辑
摘要: 1. 分支结构 -- if -- if...else...-- if...elif...else...-- if嵌套 2. 循环结构 -- while -- while...else... 了解 -- break | continue 重点 3. for循环(迭代器) -- range() 函数 阅读全文
posted @ 2019-04-16 20:13 挺锅锅 阅读(276) 评论(0) 推荐(0) 编辑
摘要: 1 name = input("Please input your name :") 2 age = input("Please input your age :") 3 sex = input("Please input your sex :") 4 job = input("Please inp 阅读全文
posted @ 2019-04-16 10:02 挺锅锅 阅读(283) 评论(0) 推荐(0) 编辑
摘要: 运算符优先级 以下所列优先级顺序按照从低到高优先级的顺序;同行为相同优先级。 阅读全文
posted @ 2019-04-15 21:45 挺锅锅 阅读(400) 评论(0) 推荐(0) 编辑