# 切片 步长写-1时,表反向输出 str_yuan = "运命重尊,然自其顺的余其,的做能己自做" # 倒叙 str1 = str_yuan[::-1] # 截取 start_index = str1.find("顺") end_index = str1.find(",尊") result = str1[start_index:end_index] # 倒叙后的结果 print(str1) # :做自己能做的,其余的顺其自然,尊重命运 # 截取的结果 print(result) # :顺其自然
标签:index,end,截取,result,字符串,find,str1 From: https://www.cnblogs.com/haha1988/p/17519787.html