【发布时间】:2022-11-30 16:27:19
【问题描述】:
我通常在 Google Colab 上运行 Python,但是我需要在 Ubuntu 的终端中运行一个脚本。
我有以下脚本 测试.py:
#!/usr/bin/env python
# testing a func
def hello(x):
if x > 5:
return "good"
else:
return "bad"
hello(2)
执行时它没有返回任何东西。现在我可以用 print 语句替换 return 语句。但是,对于我拥有的其他脚本,需要返回语句。
我试过了:
python test.py
你看,在 Google Colab 上,我可以简单地调用函数 (hello(2)),它就会执行。
期望的输出:
> python test.py
> bad
【问题讨论】:
标签: python bash ubuntu terminal