Python 中提示文件名的最佳方法是什么,以便将任何内容传递给您可以作为文件打开的函数?
尤其是通过 Pathlib 找到的字符串和文件。
def myfunc(filename: str) -> None: with open(filename) as f1: # do something here
python type-hinting python-3.x
python ×1
python-3.x ×1
type-hinting ×1