首页IT科技python中序列类型有哪些(python序列操作的整理)

python中序列类型有哪些(python序列操作的整理)

时间2025-09-01 15:30:03分类IT科技浏览5078
导读:字符串也是一种序列类型。...

字符串也是一种序列类型              。

1               、转义字符:在某些字符之前添加\               ,可以表达特殊的含义                     ,例如:\t代表缩进                      。

>>>string=Hello\nMy\tfriend >>>print(string) #Hello #Myfriend

2                     、原始字符串:在引号前添加r       ,表示不转义字符串的内容       。

>>>string=rHello\nMy\tfriend >>>print(string) #Hello\nMy\tfriend

3       、长字符串:用三个引号代替普通引号               ,表示保留文本的原始格式                     ,适用于长段       。

>>>string=Toseeaworldinagrainofsand, Andaheaveninawildflower, Holdinfinityinthepalmofyourhand, Andeternityinanhour. >>>print(string) #Toseeaworldinagrainofsand, #Andaheaveninawildflower, #Holdinfinityinthepalmofyourhand, #Andeternityinanhour.

以上就是python序列操作的整理       ,希望对大家有所帮助                      。更多Python学习指路:Python基础教程

创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!

展开全文READ MORE
如何用python将数据类型转换为字符串类型(python数据变换如何实现) vue no access-control-allow(避大坑!Vue3中reactive丢失响应式的问题)