1. 程式人生 > >strip()函數---去除字符串首尾字符

strip()函數---去除字符串首尾字符

去除 空格 strip() nbsp 函數 class color col code

#去除空
>>> s =  0000a0bc0000
>>> s.strip()
0000a0bc0000

#去除首尾字符‘0‘
>>> s = 0000a0bc0000
>>> s.strip(0)
a0bc

不傳入參數默認去除首尾空格

strip()函數只能去除首尾字符,中間的字符並不能去除

strip()函數---去除字符串首尾字符