Python: Getting AppData folder in a cross-platform way

前端 未结 4 1595
南方客
南方客 2021-02-12 20:52

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.

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-12 21:49

    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.)

提交回复
热议问题