亚洲区国产区激情区无码区,国产成人mv视频在线观看,国产A毛片AAAAAA,亚洲精品国产首次亮相在线

Python 基礎教程

Python 流程控制

Python 函數(shù)

Python 數(shù)據(jù)類型

Python 文件操作

Python 對象和類

Python 日期和時間

Python 高級知識

Python 參考手冊

Python 字符串 rstrip() 使用方法及示例

Python 字符串方法

rstrip()方法 刪除 string 字符串末尾的指定字符(默認為空格)。

rstrip()根據(jù)參數(shù)(指定要刪除的字符集的字符串)從右側(cè)刪除字符。

rstrip()的語法為:

string.rstrip([chars])

rstrip()參數(shù)

  • chars (可選)-一個字符串,指定要刪除的字符集。

如果沒有提供chars參數(shù),則從字符串中刪除右側(cè)的所有空格。

rstrip()返回值 

rstrip()返回字符串的副本,其中刪除了末尾的字符。

chars從字符串的右邊刪除參數(shù)中所有字符的組合,直到第一次不匹配為止。

示例:rstrip()的工作

random_string = ' this is good'

# 移除前導空白
print(random_string.rstrip())

# 參數(shù)不包含“ d”
# 不刪除任何字符。
print(random_string.rstrip('si oo'))

print(random_string.rstrip('sid oo'))

website = 'www.jixiangtaizi.com.cn/'
print(website.rstrip('m/.'))

運行該程序時,輸出為:

 this is good
 this is good
 this is g
www.nhooo.co

Python 字符串方法