英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论