Skip to main content
 首页 » 编程设计

python之无法在 Python 中定义函数

2025年05月04日17kenshinobiy

每当我编写一个函数然后在 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