Evolves on Mistakes
>>> 负负得正
>>> --4 负负得正
4
>>>四舍五入的规范
>>> round(8.3) #Python 2.7
8.0 #四舍五入之后仍然是 **浮点数**
>>>重新赋值的结果
>>> pi = 3.14
>>> radius = 18.9
>>> area = pi * (radius ** 2)
>>> area
1121.6393999999998
>>> radius = 22.3 #注意重新赋值radius,不改变原来area的值
>>> radius
22.3
>>> area
1121.6393999999998
>>> 对字符串的操作 #Slicing and Indexing
>>> number = 'abcd'
>>> number[1]
'b'
>>> number[3]
'd'
>>> number[-1]
'd'
>>> number[0:3] #注意Slicing与Indexing的区别,Slicing的铡刀落在截至数字的脚前
'abc'
>>> number[:-1]
'abc'
>>> number[-1:]
'd'
>>> number[-2:0]
''
>>> number[::-1] #反转词组 第三个位置,可以理解为倒车还是开车
'dcba'
网友评论