我可以使用
os.path.expanduser("~")
~/.config
$XDG_CONFIG_HOME
C:\Users\<user>\AppData\Local\Roaming
您可以利用 python 第三方库 appdirs
platformdirs