Python Route 03

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.