strip()函式是python字串函式,對字串進行操作。
功能:去掉字串頭尾指定的字元或字串行。當引數沒有時,去掉首尾空白字元。
語法格式:
string.strip(str)
名稱
含義string
指待處理的字串
str指在首尾移除的字串
無引數時:
>>> name = ' liqin \n'
>>> name
liqin \n
>>> name.strip()
liqin
有引數時:
>>> name = 'zzzliqinzzz'
>>> name
zzzliqinzzz
>>> name.strip('z')
liqin
!!
字串前後字元與要刪除的字元相同且有重複多個,那麼strip()函式會全部刪除,列如上面例子:
字串前後多個z被刪除。
Python之strip與split函式
一 strip函式原型 宣告 s為字串,rm為要刪除的字串行 s.strip rm 刪除s字串中開頭 結尾處,位於rm刪除序列的字元 s.lstrip rm 刪除s字串中開頭處,位於 rm刪除序列的字元 s.rstrip rm 刪除s字串中結尾處,位於 rm刪除序列的字元 如下 a hheloooo...
python函式學習內容 python之函式學習
usr bin env python 位置引數說明 位置引數 通過引數傳遞的位置來決定 def echo1 x,y print x format x print y format y return x y res1 echo1 2,6 print res1 關鍵字引數 關鍵字引數 通過引數名稱來決定...
strip命令學習筆記
readelf s 看到的.debug info 存放dwarf中的除錯資訊 readelf debug dump 將除錯相關的段dump出來 strip strip debug會將elf檔案的debug相關的section刪除,大大縮減了檔案的體積。readelf s filename 可以將fi...