您好,欢迎来到花图问答。
搜索
您的当前位置:首页python中双引号和单引号的区别是什么

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

来源:花图问答

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

3个单引号的作用:

1、表示注释

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

相关推荐:《》

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 = 'my name is "xxx"!'
str = "my name is 'xxx'!"

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

本文如未解决您的问题请添加抖音号:51dongshi(抖音搜索懂视),直接咨询即可。

热门图文

Copyright © 2019-2025 huatuowenda.com 版权所有 湘ICP备2023022495号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务