当前位置: 首页 > 图灵资讯 > 行业资讯> python中双引号和单引号的区别是什么

python中双引号和单引号的区别是什么

发布时间:2025-04-06 15:54:21

python3中的单引号“”和双引号“”的作用是一样的。

三个单引号的作用:

1、表示注释

#3个单引号表示注释多行
'''
gf_of_archerzon="Wang"
print("女盆友是archerzon",gf_of_archerzon)
print("女盆友是archerzon%s"%gf_of_archerzon)
'''

相关建议:Python基础教程

2、表示多行打印

msg='''
gf_of_archerzon="Wang"
print("女盆友是archerzon",gf_of_archerzon)
print("女盆友是archerzon%s"%gf_of_archerzon)
'''

输出:

gf_of_archerzon="Wang"
print("女盆友是archerzon",gf_of_archerzon)
print("女盆友是archerzon%s"%gf_of_archerzon)

一些小技巧倒可以提一下,比如:

str='mynameis"xxx"!'
str="mynameis'xxx'!"

各自的赋值包含不同的引号。

相关文章

如何让vim支持python3

如何让vim支持python3

2025-09-12
python2.7和3.6区别有哪些

python2.7和3.6区别有哪些

2025-09-12
python3有serial库吗

python3有serial库吗

2025-09-12
python中w、r表示什么意思

python中w、r表示什么意思

2025-09-12
python中如何把list变成字符串

python中如何把list变成字符串

2025-09-12
python命名空间是什么

python命名空间是什么

2025-09-12