-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpython_module.txt
91 lines (72 loc) · 1.3 KB
/
python_module.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
module
__init__.py
if __name__=='__main__':
__file__
__doc__
parameter
def fun(*args,**kargs,args='jk'):
print arg # default jk
print args # a list of arg
pring kargs # a dict
yield
with
seek=0
while True:
with open('tmp.txt','r') as f:
f.seek(seek)
data=f.readline()
if data:
seek=f.tell()
yield data
else:
return
result='gt' if 1>3 else 'lt' # if true front else behind
temp=lambda x,y,z:x+y+z
help()
dir()
vars()
type()
import tjson
reload(tjson)
id()
abs()
bool()
divmod()
max()
min()
pow()
len()
all()
any()
chr()
ord()
hex()
bin()
oct()
range()
enumerate()
s='i am {0},{1}'
s.format('fda','fb')
map()
filter()
reduce()
apply()
zip()
import json
json.dumps()
json.dump() # write to a file
json.loads()
json.load() # read from a file
eval('1+2')
model=__import__('os') # 以字符串形式导入模块,如果导入为目录则导入__init__.py
function=getattr(model,'uname') # 目录,则需要先导入一次模块,再导入一次函数
function() # 以字符串形式导入函数
hasaddr()
getaddr()
setaddr()
deladdr()
import random
random.random() # 0 or 1
random.randint(1,3) # int >=1 and <=3
random.randrange(1,3) # int >=1 and <3
json random time sys os re