kai*_*kai 4 python return pycharm
当您使用 Pycharm 编辑py
文件时,它会插入这样的模板。
def check_caller_log():
"""
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
:return:
"""
Run Code Online (Sandbox Code Playgroud)
这里的目的是什么:return:
?
它描述了函数返回的类型(例如,如果它返回一个字符串,则编写return: str
)。您还可以添加有关此返回值包含的内容或其用途的注释。
def my_function():
"""
Some good explanation of what this function does
:return: str
"""
Run Code Online (Sandbox Code Playgroud)
注意:如果你的函数没有返回任何内容,它实际上返回 None ,你可以把它写下来:return: None
def my_function():
"""
Some good explanation of what this function does
:return: None
"""
Run Code Online (Sandbox Code Playgroud)