随笔分类 -  python3每日知识积累

摘要:open('','r',encoding='') 第一个是路径,第二个是默认只读模式,第三个是编码 几种模式: 'r' 只读模式 'w' 写模式 写之前内容全部覆盖掉 'a' 追加模式 'r+' 从光标的位置开始覆盖 f = open('',encoding='') open 找的是系统的编码 data =... 阅读全文
posted @ 2018-02-19 17:41 MrZY 阅读(97) 评论(0) 推荐(0)
摘要:常用函数 abs() 绝对值 all()Return True if bool(x) is True for all values x in the iterable. If the iterable is empty, return True any()Return True if bool(x) is True for any x in the iterable. I... 阅读全文
posted @ 2018-02-14 22:29 MrZY 阅读(126) 评论(0) 推荐(0)
摘要:作用域 例1、 def test1(): print('in the test1') def test(): print('in the test') return test1() res = test() print(res) >>> in the test in the test1 None 例2、 ... 阅读全文
posted @ 2018-02-14 22:28 MrZY 阅读(145) 评论(0) 推荐(0)
摘要:局部变量 全局变量 全局变量:在整个文件里生效,在任何位置都能使用 局部变量:只能在局部使用 name = '123' def test(): name ='dfsaf' print(name) #调用现在局部找 找不到才去外面找全局变量 test() print(name) dfsaf 123 ... 阅读全文
posted @ 2018-02-13 09:16 MrZY 阅读(133) 评论(0) 推荐(0)
摘要:字符串 数字 列表 元组 字典 #############变量的分类 可变与不可变 1、可变:列表,字典 2、不可变:字符串、元组、数字 访问顺序: 1、顺序访问:字符串、列表、元组 有序 2、映射:字典 字典查询速度快 但是内存占得多 无序 3、直接访问:数字 ###################集合 1、无序、不同元素组成、集合中的元素必须位不可变型 2、表示 {} set 3... 阅读全文
posted @ 2018-02-12 12:06 MrZY 阅读(178) 评论(0) 推荐(0)
摘要:#数字 int #字符串 replace find join strip startwith endwith upper lower format 特殊的 v = template.format(**{name:'fdsa',age:'fdasf'}) #列表 append extend ... 阅读全文
posted @ 2018-02-09 21:48 MrZY 阅读(114) 评论(0) 推荐(0)
摘要:#######################list 类 列表######################## li = [1, 2, 343, 'dfas', ['fsad', 'dfas'], True] # list 是一个集合 能放任何东西进去 # print(li[0:3]) # list 是可以修改的 # 索引法 # li[1] # a = li[4][0] value = 'f... 阅读全文
posted @ 2018-02-09 21:47 MrZY 阅读(318) 评论(0) 推荐(0)
摘要:编程语言 高级 字节码 低级 机器码 python语言 javapython cpython 常用 pypy 最快 python程序: 1 终端:C:\python36\python.exe c:\1.py 解释器: 2 文件型 #/usr/bin/u/ubv/a python Linux pyth... 阅读全文
posted @ 2018-02-07 22:11 MrZY 阅读(113) 评论(0) 推荐(0)
摘要:关于数据类型的方法总结print('hello world') num=9/3 print(num) '''若干个运算符的说明 / 除 // 整除 % 取余数 != 不等于 ctrl+? 取注释 ''' # # in 和 Not in 表示在于不在 # name='李宇春' # if '李' in name :#李 为子字符串 # print('ok') # else: # p... 阅读全文
posted @ 2018-02-07 22:09 MrZY 阅读(109) 评论(0) 推荐(0)