Gray_ 发表于 2018-11-1 21:22:07

字符串问题

你好
请问一下,现在输出“Let's go!”是不是不需要转义符了

塔利班 发表于 2018-11-1 21:29:50

你用双引号字符串不用

黑曼巴24 发表于 2018-11-1 22:11:46

相同字符串不能同时出现,当字符串中已经有单引号时,使用单引号时需要加转义符\使用双引号和三引号时不需要加

vonhng 发表于 2018-11-2 00:01:35

接楼上
In : c= 'We all know that \'A\' and \'B\' are two capital letters.'

In : c
Out: "We all know that 'A' and 'B' are two capital letters."

In : d = "We all know that 'A' and 'B' are two capital letters."

In : d
Out: "We all know that 'A' and 'B' are two capital letters."

_ULTIMATE_CODER 发表于 2018-11-2 11:27:01

如果你要输出双引号的话,用
print('"Let\'s go!"')
不用双引号的话
print("Let's go!")

第五 发表于 2018-11-2 12:10:04

路过

qiyuanheng 发表于 2018-11-2 13:27:42

你用双引号字符串不用,单引号的话要用

Gray_ 发表于 2018-11-3 20:11:14

塔利班 发表于 2018-11-1 21:29
你用双引号字符串不用

感谢{:5_109:}刚开始学有点蒙

Gray_ 发表于 2018-11-3 20:11:58

黑曼巴24 发表于 2018-11-1 22:11
相同字符串不能同时出现,当字符串中已经有单引号时,使用单引号时需要加转义符\使用双引号和三引号时不 ...

感谢{:5_109:}刚开始学有点蒙

Gray_ 发表于 2018-11-3 20:13:35

vonhng 发表于 2018-11-2 00:01
接楼上
In : c= 'We all know that \'A\' and \'B\' are two capital letters.'



感谢{:5_109:}刚开始学有点蒙

Gray_ 发表于 2018-11-3 20:15:09

qiyuanheng 发表于 2018-11-2 13:27
你用双引号字符串不用,单引号的话要用

感谢{:5_109:}刚开始学有点蒙
页: [1]
查看完整版本: 字符串问题