首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我的密码怎么了?我是Python 3.3的新手

我的密码怎么了?我是Python 3.3的新手
EN

Stack Overflow用户
提问于 2013-06-16 11:19:36
回答 2查看 103关注 0票数 0
代码语言:javascript
复制
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()

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

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-06-16 11:22:26

自从Python 3print不再是语句,而是函数。因此,要使用它,您可以执行print()而不是print

Python 2.7:

代码语言:javascript
复制
print "Hello world!"

Python 3:

代码语言:javascript
复制
print("Hello world!")

您可以阅读更多关于print()函数在医生那里的信息,其中还提到了可以包含的一些参数,以及如何在python2.x (from __future__ import print_function)中使用它。

而且,在if o1 =="T"之后,您缺少了一个冒号。可能只是一个简单的错误:)。

票数 5
EN

Stack Overflow用户

发布于 2013-06-16 11:21:32

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

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

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

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17132740

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档