字符串处理与特殊函数
用引号括起来的字符集合称之为字符串,,引号可以是一对单引号,双引号,三引号(单/双)
Notes:
python中的三引号可以将复杂的字符串进行复制:python中的三引号允许一个字符串夸多行,字符串可以包含换行符,制表符,以及其他特殊字符,三引号的语法是一对连续的单引号或者双引号(通常都是成对的用)
In [70]: var1=‘you are a hero‘ In [71]: type(var1) Out[71]: str In [72]: var2="I am a girle" In [73]: type(var2) Out[73]: str In [74]: var3=‘‘‘yes you are right‘‘‘ In [76]: type(var3) Out[76]: str In [77]: var4="""gagaga is lary gaga""" In [78]: type(var4) Out[78]: str In [79]: In [79]: print("zhangsan is a ‘layde‘") zhangsan is a ‘layde‘ In [80]: print(‘zhangsan is a "layde"‘) zhangsan is a "layde"
原文地址:https://www.cnblogs.com/xindeng/p/8893054.html
时间: 2024-11-02 07:31:28