📜  python 字符串切片 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:13.697000             🧑  作者: Mango

代码示例2
my_string = "Hey, This is a sample text"
print(my_string[2:]) #prints y, This is a sample text
print(my_string[2:7]) #prints y, Th excluding the last index
print(my_string[2::2]) #prints y hsi  apetx
print(my_string[::-1]) #reverses the string => txet elpmas a si sihT ,yeH