【发布时间】:2018-11-04 20:22:25
【问题描述】:
我有以下代码:
def do_math(a, b, kind = 'add' ):
if (kind=='add'):
return a+b
else:
return a-b
do_math(1, 2)
我使用这个页面,为了将 ATOM 转换为交互模式:
https://github.com/foreshadow/atom-python-run/wiki/12-How-Do-I-Use-atom-python-run#interactive-mode
但它返回 1,而不是预期的 3。
这是截图:
Atom View, look at the returned value at the bottom...
我应该如何处理/解决这个问题,所以返回值为 3?
【问题讨论】:
-
假设您的代码已发布,它适用于我(python 3.7 IDLE)。现在,您发布的链接看起来像是您想为程序提供参数然后在代码上使用它,这是与函数参数无关的另一件事。
-
怎么不返回'3'?!
-
@lucas_7_94 我只想删除任何一段代码,并立即检查它,而不添加模块、库等。至少对于这个简单的脚本,我希望它能够工作...... :-(
标签: python function return-value interactive-mode