随笔分类 -  python

摘要:1. 形参、实参 形参,徒有其形,没有固定值,只是个形式而已。 实参,有实实在在的值,传递给函数 def test(x,y,z = 3): # x,y,z 形参 print(x,y,z) test(1,2) # 1,2 实参 2. 位置参数和默认参数 位置参数是严格按照一一对应的关系,将你的实参和位 阅读全文
posted @ 2019-10-30 13:04 wztshine 阅读(212) 评论(0) 推荐(0) 编辑
摘要:一种编码想要转成另一种编码,需要先解码成:Unicode,然后再从 Unicode 转成其他编码。 例如 GBK 格式想要转成 utf-8,需要先按照 gbk 的格式 decode 成 unicode,再从 unicode 格式 encode 成 utf-8 # python3默认使用utf-8编码 阅读全文
posted @ 2019-10-30 11:21 wztshine 阅读(217) 评论(0) 推荐(0) 编辑
摘要:参考自:https://www.cnblogs.com/alex3714/articles/5717620.html 1. 文件基础操作 f = open('test.txt') #打开文件 first_line = f.readline() # 每次读一行,并移动文件指针 print('first 阅读全文
posted @ 2019-10-29 17:46 wztshine 阅读(912) 评论(0) 推荐(0) 编辑
摘要:转自:https://www.cnblogs.com/alex3714/articles/5740985.html s = set([3,5,9,10]) # 创建一个数值集合 t = set("Hello") #创建一个唯一字符的集合 a = t | s # t 和 s的并集 b = t & s 阅读全文
posted @ 2019-10-29 17:27 wztshine 阅读(345) 评论(0) 推荐(0) 编辑
摘要:字典的特性: key唯一 无序(似乎是python3.6以后,字典默认保持插入时的顺序) '''特性:key唯一;无序''' info = { 'stu1101': "安徽", 'stu1102': "北京", 'stu1103': "河南", } # 增删查改 info["stu1104"] = 阅读全文
posted @ 2019-10-29 16:22 wztshine 阅读(817) 评论(0) 推荐(0) 编辑
摘要:转自:https://www.cnblogs.com/zhbzz2007/p/5943685.html 日志回滚部分参考自:https://www.cnblogs.com/andy9468/p/8378492.html Python标准模块--logging 1 logging模块简介 loggin 阅读全文
posted @ 2019-10-29 15:41 wztshine 阅读(407) 评论(0) 推荐(0) 编辑
摘要:name = 'ALLix9' print(name.casefold()) # 大写变成小写 name.lower() # 全变小写 name.upper() # 大写 name.title() # 首字母大写 print('10'.isnumeric()) #判断是否是数字:正整数 print( 阅读全文
posted @ 2019-10-13 21:42 wztshine 阅读(205) 评论(0) 推荐(0) 编辑
摘要:转自 菜鸟教程:https://www.runoob.com/python/att-string-format.html Python format 格式化函数 Python2.6 开始,新增了一种格式化字符串的函数 str.format(),它增强了字符串格式化的功能。 基本语法是通过 {} 和 阅读全文
posted @ 2019-10-13 19:57 wztshine 阅读(755) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示