python使用string去掉字符串末尾的標點符號
阿新 • • 發佈:2018-12-17
rip import 末尾 imp 去掉 code ctu 標點符號 out 處理要求:去掉2.0.1.中最右側的標點符號
導入string模塊,處理過程如下:
導入string模塊,處理過程如下:
In [101]: import string In [102]: a = ‘2.0.1.‘ In [103]: a Out[103]: ‘2.0.1.‘ In [104]: a = a.strip(string.punctuation) In [105]: a Out[105]: ‘2.0.1‘
python使用string去掉字符串末尾的標點符號