【发布时间】:2018-02-03 00:34:23
【问题描述】:
我是编程新手,正在尝试使用一点 Python3。
我无法理解调用函数背后的概念?定义了以下函数,调用它的正确方法是什么?
def string_length(mystring):
return len(mystring)
提前谢谢大家
【问题讨论】:
-
string_length('hello')例如 -
首先,您的间距已关闭。第二行需要缩进 4 个空格。其次,您可以通过调用它来调用它:“print string_length(this_string)”或“sl = string_length('this')”
-
请注意,
len本身就是一个您已经在调用的函数 -
你真的需要read the Python tutorial。