2018年2月25日

hashlib

摘要: import hashlib obj = hashlib .md5("sadsa".encode("utf8")) obj .update("hello".encode("utf8") ) print(obj.hexdigest()) #5d41402abc4b2a76b9719d911017c59 阅读全文

posted @ 2018-02-25 22:26 python_an 阅读(91) 评论(0) 推荐(0) 编辑

configparser

摘要: import configparser config = configparser .ConfigParser () config["DEFULT"] = {"a":"1", "b":"2", "c":"3"} config["dsadsad.org"] = {} config ["dsadsad. 阅读全文

posted @ 2018-02-25 21:37 python_an 阅读(143) 评论(0) 推荐(0) 编辑

正则

摘要: 功能:模糊匹配(针对字符串操作) re由c语言编写,效率也会快很多 .可以指代任意字符除了换行符 ^开头开始匹配 $结尾匹配 *匹配0到无穷次 +代匹配1到无穷次 ?匹配0或者1次 {}自定义匹配 import re print(re.findall("alex*","464ale") ) #['a 阅读全文

posted @ 2018-02-25 15:27 python_an 阅读(170) 评论(0) 推荐(0) 编辑

2018年2月24日

logging

摘要: 日志分5种级别 import logging logging .basicConfig( level= logging .DEBUG, filename= "logger.log", filemode= "w", format= "%(asctime)s,%(lineno)d,%(filename) 阅读全文

posted @ 2018-02-24 23:01 python_an 阅读(131) 评论(0) 推荐(0) 编辑

2018年2月22日

模块

摘要: random import random r = random .random() #随机取一个0~1的浮点数 print(r) import random r = random.randint(1, 3) # 随机取1到3的整数 r = random.randrange(1, 3) # 随机取1到 阅读全文

posted @ 2018-02-22 18:07 python_an 阅读(202) 评论(0) 推荐(0) 编辑

2018年2月13日

文件操作

摘要: 打开(pycharm默认用utf-8存储,打开文件默认用系统编码,所以编码成utf-8),默认打开是读模式 f = open("文件操作",encoding= "utf-8") data = f.read() print(data )f.close() f = open("文件操作","r",encoding= "utf-8") #data = f.read() #print(da... 阅读全文

posted @ 2018-02-13 13:03 python_an 阅读(138) 评论(0) 推荐(0) 编辑

2018年2月11日

内置函数

摘要: ascil字符转换数字 阅读全文

posted @ 2018-02-11 10:41 python_an 阅读(151) 评论(0) 推荐(0) 编辑

2018年2月10日

map函数

摘要: 将 列表里的数字平方 num_1 = [2,5,68,4,9] num_0 = [] for i in num_1 : num_0 .append(i**2) print(num_0 ) def map_test(arry): num_0 = [] for i in num_1: num_0.app 阅读全文

posted @ 2018-02-10 15:57 python_an 阅读(106) 评论(0) 推荐(0) 编辑

2018年2月8日

函数

摘要: def test(x): y=2*x+1 return y print(test(3) ) def test(): x=3 y=2*x+1 return yprint(test() ) 阅读全文

posted @ 2018-02-08 18:56 python_an 阅读(96) 评论(0) 推荐(0) 编辑

集合的使用

摘要: 集合的特点:1.无序的 2. 不同的元素组成(有去重的功能)3.不可修改 不可变列表 s = frozenset ("hello") #frozenset({'l', 'e', 'h', 'o'}) print(s) 添加 set = {"assd","445",131,("jjsda") } se 阅读全文

posted @ 2018-02-08 12:49 python_an 阅读(138) 评论(0) 推荐(0) 编辑

导航