Is there a Python idiom for creating point folders in a home directory?

I was wondering if there is an idiom for creating point folders and files for saving configuration files on all operating systems using Python.

+6
source share
1 answer

You can get the user folder with os.path.expanduser :

in win

 >>> import os, os.path >>> os.path.expanduser('~') 'C:\\Documents and Settings\\alko' 

on * nix

 >>> os.path.expanduser('~') '/home/alko' 

And create a point folder with os.mkdir (works on both):

 >>> hd = os.path.expanduser('~') >>> os.mkdir(os.path.join(hd, '.my-config')) 
+9
source

Source: https://habr.com/ru/post/958973/


All Articles