溫馨提示×

python中rstrip是什么意思

摘星
1896
2021-05-31 13:17:54
欄目: 編程語言

python中rstrip是指刪除字符串末尾指定字符的方法,rstrip的語法格式“str.rstrip([chars])”,這里chars是指定刪除的字符。

python中rstrip是什么意思

具體使用步驟:

1、首先打開python編輯器,新建一個python項目。

2、在python項目中使用rstrip方法來刪除刪除字符串末尾指定字符。

print str.rstrip('8'); #刪除字符串末尾為“8”的字符

示例代碼:

#!/usr/bin/python

str = " this is string example....wow!!! ";

print str.rstrip();

str = "88888888this is string example....wow!!!8888888";

print str.rstrip('8');

輸出結果:

this is string example....wow!!!

88888888this is string example....wow!!!

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女