python切片

2020-02-10  本文已影响0人  蜗牛会跑步
# 创建一个字符串
string = "This is a string need to be slice"
# 切片
print(string[1:])
print(string[:2])
print(string[::2])
print(string[-2:-1])
print(string[-1::-1])

his is a string need to be slice
Th
Ti sasrn edt esie
c
ecils eb ot deen gnirts a si sihT
上一篇下一篇

猜你喜欢

热点阅读