Python中有没有办法对字符串和函数进行分类?
例如
def myFunction():
a=(str(local_time[0]))
return a
b="MyFunction"+myFunction
我收到一个错误,无法连接“str”和“function”对象。
有两种可能:
如果您正在寻找 的返回值myfunction
,则:
print 'function: ' + myfunction()
如果您正在寻找myfunction
then 的名称:
print 'function: ' + myfunction.__name__
You need to call your function so that it actually returns the value you are looking for:
b="MyFunction"+myFunction()
You can use
var= "string" + str(function())
example
a="this is best"
s="number of chars. in a " + str(len(a))
print(s)