或利用索引左闭右开
s="Hello World"
print(s[-2::-1]) # lroW olleH
print(s[-2::]) # ld
print(s[2:-1]) # llo Worl
print(s[1:5]) # ello
print(s[-1:-4:-1]) # dlr
参考文章:https://blog.csdn.net/love20165104027/article/details/82750523
或利用索引左闭右开
s="Hello World"
print(s[-2::-1]) # lroW olleH
print(s[-2::]) # ld
print(s[2:-1]) # llo Worl
print(s[1:5]) # ello
print(s[-1:-4:-1]) # dlr
参考文章:https://blog.csdn.net/love20165104027/article/details/82750523