【说站】python序列操作的整理
2023-06-13 09:13:15 时间
python序列操作的整理
字符串也是一种序列类型。
1、转义字符:在某些字符之前添加\,可以表达特殊的含义,例如:\t代表缩进。
>>> string = 'Hello\nMy\tfriend'
>>> print(string)
# Hello
# My friend
2、原始字符串:在引号前添加r,表示不转义字符串的内容。
>>> string = r'Hello\nMy\tfriend'
>>> print(string)
# Hello\nMy\tfriend
3、长字符串:用三个引号代替普通引号,表示保留文本的原始格式,适用于长段。
>>> string = '''To see a world in a grain of sand,
And a heaven in a wild flower,
Hold infinity in the palm of your hand,
And eternity in an hour.'''
>>> print(string)
# To see a world in a grain of sand,
# And a heaven in a wild flower,
# Hold infinity in the palm of your hand,
# And eternity in an hour.
以上就是python序列操作的整理,希望对大家有所帮助。更多Python学习指路:python基础教程
推荐操作环境:windows7系统、Python 3.9.1,DELL G3电脑。
相关文章
- python实现矩阵的转置_Python实现矩阵转置的方法分析
- python大数据分析实例-用Python整合的大数据分析实例
- python selenium 实现快手自动评论
- 【说站】python异常处理的常见错误
- 【说站】python定义可变参数的两种形式
- python输出unicode编码_Python以utf8编码读取文件
- 最长回文子串 python_最长回文子序列
- 在python中用来安装第三方库的常用工具_什么库用于安装管理Python扩展包
- Python Django 编程 | 连载 03 - Django 视图
- python制作自动交易程序_Python如何实现自动化交易
- python定义函数求和_Python定义函数实现累计求和操作
- Python内置(6)any、数学、callable、序列操作
- Python中的时间序列数据操作总结
- python异常捕获和处理
- Python交互Redis的实现
- Linux下如何快速卸载Python环境(linux如何卸载python)
- 学习Python精通SQL Server操作技巧(python操作sqlserver)
- MySQL与Python搭配,实现数据库操作。(mysql-python)
- python使用Python轻松操作Redis(redis-)
- Linux 下 Python 升级:轻松完成升级操作(linux下升级python)
- Linux Python:开启互联网新时代(linux python)
- Python操作MySQL数据库的必备模块mysqlpython(mysql_python)
- 简单的Python抓taobao图片爬虫