在Python中,要查看函数的返回类型,你可以使用 `type()` 函数。下面是一个简单的示例:
def my_function():
return 42
result = my_function()
print(type(result)) 输出:
在这个例子中,`my_function` 函数返回一个整数,所以 `type(result)` 的输出是 `
如果函数没有显式地返回任何值,或者返回了 `None`,那么返回值的类型将是 `NoneType`。
def my_function_without_return():
pass
result = my_function_without_return()
print(type(result)) 输出:
在这个例子中,`my_function_without_return` 函数没有返回任何值,所以 `type(result)` 的输出是 `