摘要: 用python实现三体世界的模拟,实际上解的是一个四体的问题,实现了第四颗星体:行星表面温度的计算与轨迹的可视化。 阅读全文
posted @ 2018-06-16 10:12 Lief_1997 阅读(536) 评论(0) 推荐(0)
摘要: 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 ... 阅读全文
posted @ 2018-05-19 10:42 Lief_1997 阅读(111) 评论(0) 推荐(0)
摘要: 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 # [[实例变... 阅读全文
posted @ 2018-05-19 10:41 Lief_1997 阅读(153) 评论(0) 推荐(0)
摘要: hashlib模块 用于加密相关的操作,3.x里代替了md5模块和sha模块,主要提供 SHA1, SHA224, SHA256, SHA384, SHA512 ,MD5 算法 logging模块 很多程序都有记录日志的需求,并且日志中包含的信息即有正常的程序访问日志,还可能有错误、警告等信息输出, 阅读全文
posted @ 2018-05-05 11:13 Lief_1997 阅读(147) 评论(0) 推荐(0)
摘要: 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... 阅读全文
posted @ 2018-05-05 10:56 Lief_1997 阅读(113) 评论(0) 推荐(0)
摘要: 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 # 字母和... 阅读全文
posted @ 2018-05-03 14:58 Lief_1997 阅读(135) 评论(0) 推荐(0)
摘要: 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()) ... 阅读全文
posted @ 2018-05-03 14:56 Lief_1997 阅读(108) 评论(0) 推荐(0)
摘要: json 序列化 json 反序列化 阅读全文
posted @ 2018-04-13 21:49 Lief_1997 阅读(119) 评论(0) 推荐(0)
摘要: 1 # 可迭代的数据类型 和 迭代器 2 3 from collections import Iterator 4 from collections import Iterable 5 '''可作用于 for 循环的对象都可迭代 6 可作用于 next() 函数的都是迭代器''' 7 8 # 列表、字典、元组都可迭代,但都不是迭代器 9 print('列表、字典、元组、字符... 阅读全文
posted @ 2018-04-04 18:59 Lief_1997 阅读(152) 评论(0) 推荐(0)
摘要: 列表生成式 斐波那契数列 多线程的实现 阅读全文
posted @ 2018-04-04 18:58 Lief_1997 阅读(193) 评论(0) 推荐(0)