import pathlib pathlib.Path("/tmp/path/to/desired/directory").mkdir(parents=True, exist_ok=True). 该 exist_ok 参数是在Python 3.5 中添加的。
確定! 回上一頁