introducePython

Resource Code: ‘/anaconda3/lib/python3.6/timeit.py’
Numbers,Strings,Variables

  1. In python ,everything :boolean, integer, float, even large data structure, function and programs os implements as a object.
    2.how to change a str:
    For example:
    name=‘Henny’
    name.replace(‘H’,‘P’)
    Out[17]: ‘Penny’
    ‘P’+name[1:]
    Out[18]: ‘Penny’
    3.Slice[startstep]:
    For example:
    letters=‘abcdefghijklmnopqrstuvwxyz’

letters[:]
Out[20]: ‘abcdefghijklmnopqrstuvwxyz’

letters[20:]
Out[21]: ‘uvwxyz’

letters[10:]
Out[22]: ‘klmnopqrstuvwxyz’

letters[12:15]
Out[23]: ‘mno’

#doesnt include the lasted offsets

#the three last characters as below:

letters[-3:]
Out[26]: ‘xyz’

letters[18:-3]
Out[27]: ‘stuvw’

letters[-6:-2]
Out[28]: ‘uvwx’

letters[::7]
Out[29]: ‘ahov’

letters[4:20:3]
Out[30]: ‘ehknqt’

letters[19::4]
Out[31]: ‘tx’

lette

你可能感兴趣的:(introducePython)