返回声明的目的是什么?返回语句的简单基本解释是什么,如何在Python中使用它?它和print口供?
3 回答
慕尼黑的夜晚无繁华
TA贡献1864条经验 获得超6个赞
print()
return
return
print()
return
:
def foo(): print("hello from inside of foo") return 1
if __name__ == '__main__': print("going to call foo") x = foo() print("called foo") print("foo returned " + str(x))
.py
going to call foo hello from inside foo called foo foo returned 1
>>> def foo():... print("hello from within foo")... return 1...>>> foo()hello from within foo1>>> def bar():... return 10 * foo()...>>> bar()hello from within foo10
foo()
bar()
bar()
.
print()
return
添加回答
举报
0/150
提交
取消