复习链接:An Informal Introduction to Python
>>> 8/2 4.0 >>> 4/6 0.6666666666666666 >>>
>>> 8/2 4.0 >>> 4/6 0.6666666666666666 >>>
>>> 8/2 4.0 >>> 4/6 0.6666666666666666 >>>
>>> 3*5.3 15.899999999999999 >>> 4+5.5 9.5
>>> 3*5.3 15.899999999999999 >>> 4+5.5 9.5
>>> print(‘C:\some\name‘) C:\some ame >>> print(r‘C:\some\name‘) C:\some\name
>>> ‘ba‘*5+‘ha‘ ‘bababababaha‘ >>> ‘ba‘*5+‘aaaaddddda‘ ‘bababababaaaaaddddda‘ >>>
‘dddddddaa‘ >>> test=(‘heiheiaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa‘ ... ‘bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb‘) >>> print(test) heiheiaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb >>>
>>> text[-1] ‘c‘ >>> text[-9] ‘a‘ >>>
>>> text="abcd" >>> text[0:1] ‘a‘
>>> text="abcde" >>> text[5] Traceback (most recent call last): File "<stdin>", line 1, in <module> IndexError: string index out of range >>> text[9:90] ‘‘ >>> text[2:90] ‘cde‘ >>>
>>> text="opq" >>> text[0]=‘a‘ Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: ‘str‘ object does not support item assignment >>> text="apq"
原文:https://www.cnblogs.com/bibi-feiniaoyuan/p/9300802.html