0
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()

这只会导致语法错误,我不知道为什么。非常感谢您的帮助 :-)

4

2 回答 2

5

从 Python 3 开始print不再是语句,而是函数。因此,要使用它,您可以print()代替print.

蟒蛇 2.7:

print "Hello world!"

蟒蛇 3:

print("Hello world!")

您可以在文档中阅读有关该print()函数的更多信息,其中还提到了一些可以包含的参数,以及如何在 python 2.x ( )中使用它from __future__ import print_function


此外,您在if o1 =="T". 可能只是一个简单的错字:)。

于 2013-06-16T11:22:26.293 回答
3

print是 Python 3 中的函数,不再是语句。像其他任何调用一样调用它(只需在每个调用中包含括号)。

Python2.x:print 'some string',Python3.x:print('some string')

您可以在 Python2.6 及更高版本中通过包含from __future__ import print_function作为文件的第一个导入来获得相同的行为。

于 2013-06-16T11:21:32.317 回答