First, the module initial
Import Sys
Print (Sys.path) #打印python的环境
Print (SYS.ARGV) #打印相对路径
Print (sys.argv "2") #打印对应的变量
Import OS
cmd = Os.system ("dir")
Print (CMD)
Os.mkdir (' New_dir ')
#第三方库
In the same directory or under Lib/site-package can be directly import, other cases need to write the path
Import
Data operations:
3/2 ==1
5%2 ==1 return remainder
! =
<>
8bit =byte
1024byte=1kbyte
1024kbyte=1mbyte
1024mb=1gb
2014gb=1t
& | ^ (XOR) ~ (invert) >> right shift << left shift
STR and binary conversions
Operation of the list
names = [' Zhangyang ', ' Guyun ', ' Xiangpeng ', ' Xuliangchen ']
Print (names)
Print (names[0],names[2])
Print (Names[0:2]) #切片, Gu Tou regardless of the tail
Print (names[0:])
Print (Names[-1])
Print (names[-3:])
Names.append ("Leihaidong")
Names.insert (1, ' Chenronghua ')
Names.insert (3, ' Xinzhiyun ')
names[2]= ' Xiedi ' #names. Pop (2)
Names.remove (' Chenronghua ')
Del Names[1]
Names.pop () #删除最后一个
Print (Names.index (' Xiedi '))
Print (Names[names.index (' Xiedi ')])
Print (Names.count (' Xiedi '))
Names.clear ()
Names.reverse () #反转
Names.sort () #排序
names1=[1,2,3,4]
Names.extend (NAMES1)
Names2 = Names.copy () #浅copy
names[1]= ' SD '
Print (Names,names2) #names变了, names2 unchanged
#但是names还有一层的话, all changed.
Import Copy
Names3 = copy.copy (names)
Names3 = copy.deepcopy (names)
For I in Range (1,10,2):
Print (i)
Python Route 03