1.分割字符串split
>>> filename = "iamge.png" >>> segments = filename.split(".") >>> segments[0] ‘iamge‘ >>> segments[1] ‘png‘
2.查找特定字符串
>>> dir=r"C:\Users\username\haha\app\haha" #反向查找 >>> dir.rfind("haha") 27 #正向查找 >>> dir.find("haha") 18
3.拼接字符串
>>> "hello"+" python" ‘hello python‘
时间: 2024-11-06 09:45:20