from os import path
exec_path = path.dirname(file)
print(exec_path,type(exec_path))
from pathlib import Path,PurePath
cur_path = Path(file).parent
print(cur_path,type(cur_path))
e:/TestProject/iaas/test_data <class ‘str’>
e:\TestProject\iaas\test_data <class ‘pathlib.WindowsPath’>
https://juejin.cn/post/6986882326248718373