如何编写打印在引号内的加号符号的代码?

huangapple go评论84阅读模式
英文:

How should I write the code that prints the plus sign enclosed in quotation marks?

问题

我无法打印包含在引号中的加号符号。

尝试了以下方法:

print("String Concatenation is done with the + sign.")

print("String Concatenation is done with the '+' sign.")

print("String Concatenation is done with the \"+\"+\"\" sign.")

print("String Concatenation is done with the \"+\"+\" sign.")

print("String Concatenation is done with the \"\"\" + \"\"\" sign.")
英文:

I could not print the plus sign enclosed in quotation marks.

Tried the following:

print("String Concatenation is done with the "+" sign.")

print("String Concatenation is done with the '"+"' sign.")

print("String Concatenation is done with the "\"+\"" sign.")

print("String Concatenation is done with the "\"+"\" sign.")

print("String Concatenation is done with the """ "+" """ sign.")

答案1

得分: 1

print("需要像这样转义引号:\n\nprint("String Concatenation is done with the "+" sign.")")

英文:

You need to escape the quotation marks like this:

print("String Concatenation is done with the \"+\" sign.")

答案2

得分: 1

你可以使用 "\"。符号 \ "排除" 下一个字符,如果它是引号!

print("\"Hello World\", said Harry")

另一种方法是在开头和结尾使用 '

print('"Hello World", said Harry'')

英文:

You can use "\". The sign \ "excludes" the next character if it is quotation marks!

print("\"Hello World\", said Harry")

Another way would be to use ' at the start and beginning:

print('"Hello World", said Harry')

答案3

得分: -1

print("字符串拼接使用 "'"+"'" 符号完成。")
另外,加号应该被包含在双-单-双引号内。

英文:

After doing other trials-and-errors, finally came up with the right solution:

print("String Concatenation is done with the "'"+"'" sign.")

plus sign should be enclosed in double-single-double quotation marks.

huangapple
  • 本文由 发表于 2023年7月13日 22:05:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/76680284.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定