我试图在Powershell上运行Python 2.7代码,但是由于3.7是我安装的主程序,所以它不起作用。我需要运行哪几行代码才能切换到2.7?
我尝试使用别名python = python2.7,但仅适用于Mac OS。
x = "There are %d types of people." % 10
binary = "binary"
do_not = "don't"
y = "Those who know %s and those who %s." % (binary, do_not)
print x
print y
print "I said: %r." % x
print "I also said: '%s'." % y
hilarious = False
joke_evaluation = "Isn't that joke so funny?! %r"
print joke_evaluation % hilarious
w = "This is the left side of... "
e = "a string with a right side!"
print w + e
我尝试运行python 5.py
,这是我得到的:
File "5.py", line 6
print x
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(x)?