我有一个关于如何打印的练习。我试着打印这段代码:
print "Hello World!."
print "Hello Again."
print "I like typing this."
print "this is fun."
print "Yay, Printing."
print "I would much rather you 'not'."
print "I "Said" do not touch this."
但是当我尝试在终端上运行时,它会给我一个错误:
File "ex1.py", line 7
print "I "Said" do not touch this."
^
SyntaxError: invalid syntax
答案 0 :(得分:0)
如果要打印实际引号,则需要......
用反斜杠逃脱它们:
print "I \"Said\" do not touch this."
或者将整个字符串括在另一种引号中(单一与双重):
print 'I "Said" do not touch this.'