日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產(chǎn)品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Python教程:Pythonrstrip()

python 中的rstrip()函數(shù)根據(jù)給定的參數(shù)刪除原始字符串副本中的尾隨字符。方法將此副本作為輸出返回。

 **string.rstrip([chars])** #where chars are those to remove from right 

rstrip()參數(shù):

函數(shù)的作用是:將一組字符作為參數(shù)。如果未提供字符,則從字符串中刪除尾隨空格。

參數(shù) 描述 必需/可選
燒焦 要作為尾隨字符移除的字符 可選擇的

rstrip()返回值

返回值始終是字符串。在找到第一個匹配之前,所有字符組合都將從右側開始移除。

| 投入 | 返回值 | | 線 | 字符串的副本 |

Python 中rstrip()方法的示例

示例rstrip()在 Python 中是如何工作的?

 string1 = "     python     "

string2 = string1.rstrip()

print("of all programming languages", string2, "is my favorite") 

輸出:

 of all programming languages     python is my favorite 

示例 2:在 Python 中使用rstrip()

 # Variable declaration  
string1 = "Python and Java* "  
# Calling function  
string2 = string1.rstrip(*)  
# Displaying result  
print("Before strip: ",string1)  
print("After strip: ",string2) 

輸出:

 Before strip:  Python and Java* 
After strip:  Python and Java 

名稱欄目:創(chuàng)新互聯(lián)Python教程:Pythonrstrip()
URL鏈接:http://www.dlmjj.cn/article/cddhgjd.html