Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/365.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python ex1.py-Won';t在第7行打印_Python_Python 2.7_Printing - Fatal编程技术网

Python ex1.py-Won';t在第7行打印

Python ex1.py-Won';t在第7行打印,python,python-2.7,printing,Python,Python 2.7,Printing,我做了一个关于如何打印的练习。我试图打印此代码: 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 "ex

我做了一个关于如何打印的练习。我试图打印此代码:

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

如果要打印实际的引号,则需要

用反斜杠避开他们:

print "I \"Said\" do not touch this."
或者将整个字符串括在另一种引号中(单引号与双引号):


在不转义的情况下,不能将双引号放在双引号中-
表示
在字符串之外。我明白了,如何使用双引号打印它。任何解决方案?可能重复
print 'I "Said" do not touch this.'