Python: Getting AppData folder in a cross-platform way
问题 I'd like a code snippet that gets the proper directory for app data (config files, etc) on all platforms (Win/Mac/Linux at least). For example: %APPDATA%/ on Windows. 回答1: If you don't mind using the appdirs module, it should solve your problem. (cost = you either need to install the module or include it directly in your Python application.) 回答2: Qt's QStandardPaths documentation lists paths like this. Using Python 3.8 import sys import pathlib def get_datadir() -> pathlib.Path: """ Returns a