[英]Using something other than single or double quotes to set variable?
我有一些包含许多单引号和双引号的硬编码文本。
text = "get in the "van" I said get in the 'van'"
我可以使用\\对每个双引号进行转义,也可以在外部切换为单引号并对每个单引号进行转义。
我想做的就是能够选择其他东西,例如! 我能做些简单的事情吗? 在Perl中,我始终能够:
text = qq!this will use "whatever" I'm happy with!
如果有帮助,我正在使用Python 3.6。
初始化字符串的另一个选项是使用"""
或'''
:
text = """get in the "van" I said get in the 'van'"""
您还可以串联多个字符串
text = 'get in the "van" I said get in the ' "'van'"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.