|
In [607]: lst = ['i','am','martin']
In [608]: lst
Out[608]: ['i', 'am', 'martin']
In [609]: ' '.join(lst)
Out[609]: 'i am martin'
In [610]:
In [610]: s = 'i love python'
In [611]: s.split()
Out[611]: ['i', 'love', 'python']
In [612]: ' love python'.split()
Out[612]: ['love', 'python']
In [613]: ' love python'.split(' ')
Out[613]: ['', '', '', '', '', '', 'love', 'python']
In [614]: s.split(maxsplit=1)
Out[614]: ['i', 'love python']
In [615]: s = '''i am martin
...: i love python'''
In [616]: s.splitlines()
Out[616]: ['i am martin', 'i love python']
In [617]: 'i am martin'.partition(' ')
Out[617]: ('i', ' ', 'am martin')
In [618]: cfg = 'env = PATH=/usr/bin;$PATH'
In [619]: cfg.partition('=')
Out[619]: ('env ', '=', ' PATH=/usr/bin;$PATH')
In [620]: s = 'test'
In [621]: s.upper()
Out[621]: 'TEST'
In [622]: s.upper().lower()
Out[622]: 'test'
In [623]: s.title()
Out[623]: 'Test'
In [624]: s.center(30)
Out[624]: ' test '
In [625]: s = 'hahahah hehe'
In [626]: s.strip()
Out[626]: 'hahahah hehe' |
|
|