摘要: 1 d1 = {'one': 1, 'two': 2} 2 d2 = {'one': 1, 'two': 2} 3 d3 = {'one': 1, 'two': 2} 4 print(dir(d1)) 5 6 # 1、contians 7 print('one' in d1) 8 9 # 2、eq 10 print(d1 == d2) 11 12 # 3、len 13 p... 阅读全文
posted @ 2018-01-26 14:19 魂~ 阅读(301) 评论(0) 推荐(0) 编辑
摘要: 1 # 1、+ 2 list1 = [1, 2, 3, 4] 3 list2 = [5, 6, 7, 8] 4 list3 = [1, 2, 3, 4] 5 6 print(list1 + list2) 7 print(list1) 8 print(list2) 9 10 11 # 2、contains 12 print(1 in list1) 13 14 15 # ... 阅读全文
posted @ 2018-01-26 12:30 魂~ 阅读(329) 评论(0) 推荐(0) 编辑
摘要: 链接地址 阅读全文
posted @ 2018-01-22 12:32 魂~ 阅读(348) 评论(0) 推荐(0) 编辑
摘要: 1 import random 2 3 print(random.random()) # [0, 1),浮点数 4 print(random.uniform(1, 10)) # [1, 10]浮点数 5 print(random.randrange(1, 10)) # 不包括10 6 print(random.randi... 阅读全文
posted @ 2018-01-22 12:16 魂~ 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 1 import configparser 2 3 4 """ 5 sections() 返回所有的section 6 has_section(section) 判断是否有指定的section 7 has_option(section, option) 判断是否有指定的section中的option 8 options(section) 返回指定section中的所有opti... 阅读全文
posted @ 2018-01-22 10:25 魂~ 阅读(431) 评论(0) 推荐(1) 编辑
摘要: 1 import unittest 2 import random 3 4 5 class Operation(object): 6 7 def __init__(self, num1=0, num2=0): 8 if not (0 <= num1 <= 10 and 0 <= num2 <= 10): 9 raise Ou... 阅读全文
posted @ 2018-01-19 15:47 魂~ 阅读(313) 评论(0) 推荐(0) 编辑
摘要: 1 import timeit 2 import math 3 4 5 def myfun(): 6 for i in range(100): 7 for j in range(2, 10): 8 math.pow(i, 1/j) 9 10 timeitObj = timeit.Timer(stmt=myfun) 11 t1... 阅读全文
posted @ 2018-01-19 14:32 魂~ 阅读(260) 评论(0) 推荐(0) 编辑
摘要: 1 import time 2 import datetime 3 4 """ 5 datetime模块用于是date和time模块的合集,datetime有两个常量,MAXYEAR和MINYEAR,分别是9999和1. 6 datetime模块定义了5个类,分别是 7 1.datetime.date:表示日期的类 8 2.datetime.datetime:表... 阅读全文
posted @ 2018-01-19 14:09 魂~ 阅读(1240) 评论(0) 推荐(0) 编辑
摘要: EventManager.py test.py 阅读全文
posted @ 2018-01-18 22:38 魂~ 阅读(3125) 评论(0) 推荐(1) 编辑
摘要: 1 import time 2 3 # 2种表示时间的方法: 4 # (1)时间戳,从1970.1.1开始 5 # (2)一个9个整数的元组 6 # 这个元组内容: 7 # year (including century, e.g. 1998) 8 # month (1-12) 9 # day (1-31) 10 ... 阅读全文
posted @ 2018-01-18 17:04 魂~ 阅读(390) 评论(0) 推荐(0) 编辑