每当我编写一个函数然后在 Shell 中运行它时,它就会出现空白。我只编程了大约一个月,所以不要让事情变得非常困难。
我的代码如下所示:
def intro():
print("hello world")
然后当我运行它时,它 . 没有空中消息弹出。除了在我的代码中,两行是接触的
每当我编写一个函数然后在 Shell 中运行它时,它就会出现空白。我只编程了大约一个月,所以不要让事情变得非常困难。
我的代码如下所示:
def intro():
print("hello world")
然后当我运行它时,它 . 没有空中消息弹出。除了在我的代码中,两行是接触的
你写了一个函数;现在你必须告诉它运行函数!
尝试
def intro(): # <= this tells Python what "intro" means
print("hello, world")
intro() # <= this tells Python to actually do it
你需要调用你的函数!intro()
在定义函数之后执行此操作(休在我的答案上方有一个很好的例子)。最好先阅读一些基础知识;) 如果您有兴趣,Codeacademy有很棒的 Python 课程。