python语法学习

1.整除与幂运算

>>> 5.6//2

2.0

>>> 2**3

8

>>> 

 

2.位移与异或算法

>>> 1<<1

2

>>> 1>>1

0

>>> 1^2

 

3.字符串

>>> str="abcde"

>>> str[1:4]

'bcd'

>>> str[2:]

'cde'

>>> str[::1]  //表示一步一取

'abcde'

>>>

3

>>> 2^3

1

>>> str[-1]

'e'

>>> str*2

'abcdeabcde'

>>> "c" in str

True

>>>

 

4.元组定义

>>> t=("a","b")

>>> t

('a', 'b')

>>> t[0]

'a'

>>>

posted @ 2016-02-16 00:12  lecong-Lee  阅读(329)  评论(0编辑  收藏  举报