AdSense

2019年8月23日 星期五

Python擷取部份的字串

出處
http://blog.e-happy.com.tw/python-%E6%93%B7%E5%8F%96%E9%83%A8%E4%BB%BD%E7%9A%84%E5%AD%97%E4%B8%B2%EF%BC%9Aslicing/


字串中取反轉子字串

如果想要取得反轉的子字串,只要將間隔值設為「-1」,例如:
string = "python"
print(string[::-1])
# 輸出為 nohtyp

沒有留言:

張貼留言