摘要: from xml.etree import ElementTree as ET # 方式一,通过Element这个类来创建element # 创建element ele = ET.Element("Family", {"age": "40"}) # 创建ElementTree tree = ET.E 阅读全文
posted @ 2021-02-16 16:49 xuwenwei 阅读(521) 评论(0) 推荐(0) 编辑
摘要: 对http发起请求,获取请求的返回值,返回的是字符串形式的, jason数据(类似字典,列表的字符串) XML HTML 方法一: 使用 urllib模块。 from urllib import request# f = request.urlopen("https://www.cnblogs.co 阅读全文
posted @ 2021-02-16 12:25 xuwenwei 阅读(396) 评论(0) 推荐(0) 编辑
摘要: format方式 数字格式的定义以 ':' 号开始。碰到了': '字符就知道要定义一个数字的显示格式了。格式的定义顺序为 [[fill]align][sign][#][0][width][,][.precision][type] fill 【可选】空白处填充的字符 align 【可选】对齐方式(需配 阅读全文
posted @ 2021-02-14 22:06 xuwenwei 阅读(57) 评论(0) 推荐(0) 编辑
摘要: python字符串格式化 Python的字符串格式化有两种方式:%格式符方式,format方式 %格式符 %[(name)][flags][width].[precision]typecode (name) 可选,用于选择指定的key flags 可选,可供选择的值有: + 右对齐;正数前加正好,负 阅读全文
posted @ 2021-02-14 22:05 xuwenwei 阅读(34) 评论(0) 推荐(0) 编辑
摘要: # !/usr/bin/env python # -*- coding:utf8 -*- import hashlib def login(username, pwd): with open("user.db", 'r', encoding='utf-8') as f: while True: li 阅读全文
posted @ 2021-02-14 21:46 xuwenwei 阅读(44) 评论(0) 推荐(0) 编辑
摘要: import hashlib hash = hashlib.md5(bytes('88888', encoding='utf-8')) hash.update(bytes('1235678', encoding='utf-8')) print(hash.hexdigest()) 阅读全文
posted @ 2021-02-14 20:19 xuwenwei 阅读(16) 评论(0) 推荐(0) 编辑
摘要: https://blog.csdn.net/legend818/article/details/95165703 程序开始运行,从上往下解释,读到def outer(func):的时候,发现这是个“一等公民”函数,于是把函数体加载到内存里,然后过。 读到@outer的时候,程序被@这个语法糖吸引住了 阅读全文
posted @ 2021-01-21 15:02 xuwenwei 阅读(192) 评论(0) 推荐(0) 编辑
摘要: from functools import wraps def logit(func): @wraps(func) def with_logging(*args, **kwargs): print(func.__name__ + " was called") return func(*args, * 阅读全文
posted @ 2021-01-21 13:41 xuwenwei 阅读(42) 评论(0) 推荐(0) 编辑
摘要: 函数装饰器,可以在不改变原来的函数的情况下,在原来的函数的前面或者后面添加动作。 Do something before 原来的函数动作 Do something after 基本流程如下: 1. 首先定义要添加的功能函数 def 装饰的函数(参数,此参数用来传入正常函数的函数名) def Wrap 阅读全文
posted @ 2021-01-21 11:00 xuwenwei 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 用于序列化的两个模块 json:用于字符串和Python数据类型间进行转换 pickle: 用于python特有的类型和python的数据类型间进行转换 json提供四个功能:dumps,dump,loads,load pickle提供四个功能:dumps,dump,loads,load pickl 阅读全文
posted @ 2021-01-19 15:33 xuwenwei 阅读(67) 评论(0) 推荐(0) 编辑