Python 3.x 对返回文件的函数进行注释的正确方法是什么?
我正在注释一个返回html文件的函数。输出的正确类型是什么?现在我用的是object,但可能太宽了Python 3.x 对返回文件的函数进行注释的正确方法是什么?,python-3.x,types,annotations,Python 3.x,Types,Annotations,我正在注释一个返回html文件的函数。输出的正确类型是什么?现在我用的是object,但可能太宽了 @app.route('/') def homepage() -> object: """ This function loads the homepage. :return: the homepage index.html """ return send_from_directory( os.path.join(app.root_path, 'templates'), "
@app.route('/')
def homepage() -> object:
"""
This function loads the homepage.
:return: the homepage index.html
"""
return send_from_directory(
os.path.join(app.root_path, 'templates'),
"index.html"
)
有什么建议吗?谢谢大家! 无论从目录中发送什么,都会返回。。。执行
打印(键入(从\u目录()结束\u)
然后看看它是什么类型…是文件
对象吗?是str
对象吗?是字节
对象吗?这是一个明智的建议!输出的类型是:但给出的答案仍然太宽泛了…这就是对象的类型…如果你想准确地记录这个对象的性质,那就是它的功能这是给你的