python 字符串翻转| 单词翻转

>>> s = ‘hello world python’

>>> s1 = s[::-1]

>>> s1

‘nohtyp dlrow olleh’

>>> s2 = s.split(‘ ‘)

>>> s2.reverse()

>>> s2

[‘python’, ‘world’, ‘hello’]

>>>

《python 字符串翻转| 单词翻转》

    原文作者:huisheng
    原文地址: https://www.jianshu.com/p/ae4ec933f4d9
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞