def start():
import os
os.system("cls")
print "*A Wise man once said “Be the change that you wish to see in the world.” This is the idea you have decided to live by and strive for in your quest for making a better world. You are Noah Vis, CEO of the tech giant GAIA and currently the richest man in the world, surpassing the likes of Bill Gates and Waren Buffet by a great margin. Born into a life of modest privilege in the state of Washington, you rapidly asserted your engineering and scientific abilities to build a global technological empire. Your first breakthrough was the F.E.H.C (Fusion Energy Hydrogen Collider). Producing sustainable energy by mashing the two hydrogen isotopes, deuterium and tritium, together at such high energies that they combiine into one atom. After the fusion, you produce a helium and a free neutron. The critical part being that helium+neutron has less mass than deuterium+tritium, and the mass is converted into purge energy. That energy is then captured as heat and used to run a traditional steam-driven turbine. This invention, emerging just as the world's oil supplies reach a critical low, becomes essential. As the middle east decended into conflict, the rest of the world rebuilded using your patents and products. For the most part, people are grateful. Still focused on making the world better, your focus turns. Do you...*"
print "*[L]ook to the poverty of Africa as the greatest remaining blight on Earth, and resolve to try to bring it to an end, or [T]HIS HAS YET TO BE WRITTEN*"
o1 = (input('>>'))
if o1 =="L":
print "*THIS IS NOT WRITTEN YET*"
if o1 =="T"
print "*THIS IS NOT WRITTEN YET*"
os.system("pause >Nul")
def menu ():
print "Menu\n"
print "(1)Start"
print "(2)Exit\n\n"
choice = (input('>>'))
if choice=="1":
start()
if choice=="2":
quit()
menu()
这只会导致语法错误,我无法弄清楚原因。非常感谢您的帮助: - )
答案 0 :(得分:5)
Since Python 3,print
不再是声明,而是一个函数。因此,要使用它,您需要print()
而不是print
。
Python 2.7:
print "Hello world!"
Python 3:
print("Hello world!")
您可以阅读有关print()
函数at the docs的更多信息,其中还提到了您可以包含的一些参数,以及如何在python 2.x中使用它(from __future__ import print_function
)< / p>
此外,您在if o1 =="T"
之后错过了冒号。可能只是一个简单的拼写错误:)。
答案 1 :(得分:3)
print
是Python 3中的一个函数,不再是语句。像对待其他任何一样调用它(只需在每个调用中包括括号)。
Python2.x:print 'some string'
,Python3.x:print('some string')
您可以在Python2.6及更高版本中获得相同的行为,包括from __future__ import print_function
作为您文件的第一个导入。