GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.runoob.com — Python rstrip()方法 | 菜鸟教程
Python 基础教程
Python 基础教程
Python 简介
Python 环境搭建
Python 中文编码
Python VS Code
Python 基础语法
Python 变量类型
Python 运算符
Python 条件语句
Python 循环语句
Python While 循环语句
Python for 循环语句
Python 循环嵌套
Python break 语句
Python continue 语句
Python pass 语句
Python Number(数字)
Python 字符串
Python 列表(List)
Python 元组
Python 字典(Dictionary)
Python 日期和时间
Python 函数
Python 模块
Python 文件I/O
Python File 方法
Python 异常处理
Python OS 文件/目录方法
Python 内置函数
Python 高级教程Python 面向对象 Python 正则表达式 Python CGI 编程 Python MySQL Python 网络编程 Python SMTP Python 多线程 Python XML 解析 Python GUI 编程(Tkinter) Python2.x 与 3.x 版本区别 Python IDE Python JSON Python AI 绘画 Python 100例 Python 测验Python rstrip()方法描述Python rstrip() 删除 string 字符串末尾的指定字符,默认为空白符,包括空格、换行符、回车符、制表符。 语法rstrip()方法语法: str.rstrip([chars]) 参数
返回值返回删除 string 字符串末尾的指定字符后生成的新字符串。 实例以下实例展示了 rstrip() 函数的使用方法: 实例
#!/usr/bin/python # -*- coding: UTF-8 -*- random_string = 'this is good ' # 字符串末尾的空格会被删除 print(random_string.rstrip()) # 'si oo' 不是尾随字符,因此不会删除任何内容 print(random_string.rstrip('si oo')) # 在 'sid oo' 中 'd oo' 是尾随字符,'ood' 从字符串中删除 print(random_string.rstrip('sid oo')) # 'm/' 是尾随字符,没有找到 '.' 号的尾随字符, 'm/' 从字符串中删除 website = 'www.runoob.com/' print(website.rstrip('m/.')) # 移除逗号(,)、点号(.)、字母 s、q 或 w,这几个都是尾随字符 txt = "banana,,,,,ssqqqww....." x = txt.rstrip(",.qsw") print(x) # 删除尾随字符 * str = "*****this is string example....wow!!!*****" print (str.rstrip('*')) print(x) 以上实例输出结果如下: this is good this is good this is g www.runoob.co banana *****this is string example....wow!!!
AI 思考中...
点我分享笔记取消
分类导航
Advertisement
|
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |