05 2018 档案
摘要:1 # class People: # 经典类 2 class People(object): # 新式类, super 也是新式类的写法 3 def __init__(self,name,age): 4 self.name = name 5 self.age = age 6 self.friends = [] 7 ...
阅读全文
摘要:1 # 类 2 class Role: 3 def __init__(self, name, character, weapon, skills=10, life_value=10000, money=30000, level=99): 4 # 构造函数,在实例化时做一些类的初始化工作 5 self.name = name # [[实例变...
阅读全文
摘要:hashlib模块 用于加密相关的操作,3.x里代替了md5模块和sha模块,主要提供 SHA1, SHA224, SHA256, SHA384, SHA512 ,MD5 算法 logging模块 很多程序都有记录日志的需求,并且日志中包含的信息即有正常的程序访问日志,还可能有错误、警告等信息输出,
阅读全文
摘要:1 # xml 处理 2 import xml.etree.ElementTree as ET 3 4 tree = ET.parse("xml_test.xml") 5 root = tree.getroot() 6 print(root.tag) 7 8 # 遍历xml文档 9 for child in root: 10 print(child.tag, chi...
阅读全文
摘要:1 # 生成随机验证码 2 import random 3 import string 4 5 from random import * 6 7 print(uniform(0, 90)) # 浮点数 8 print(randint(0, 10)) # 整数,包括10 9 print(randrange(1, 49)) # 不包括49 10 11 12 # 字母和...
阅读全文
摘要:1 import time 2 3 4 # print(time.clock()) #返回处理器时间,3.3开始已废弃 , 改成了time.process_time()测量处理器运算时间,不包括sleep时间,不稳定,mac上测不出来 5 # print(time.altzone) #返回与utc时间的时间差,以秒计算\ 6 # print(time.asctime()) ...
阅读全文

浙公网安备 33010602011771号