python 字符串翻转| 单词翻转
2017-10-03 本文已影响5人
huisheng
>>> s = 'hello world python'
>>> s1 = s[::-1]
>>> s1
'nohtyp dlrow olleh'
>>> s2 = s.split(' ')
>>> s2.reverse()
>>> s2
['python', 'world', 'hello']
>>>
>>> s = 'hello world python'
>>> s1 = s[::-1]
>>> s1
'nohtyp dlrow olleh'
>>> s2 = s.split(' ')
>>> s2.reverse()
>>> s2
['python', 'world', 'hello']
>>>