python os path code example
Example 1: PYTHON INSTALL DIR = os.path.dirname(os.path.dirname(os.__file__)) AttributeError: module 'os' has no attribute '_file_'
import os
path = "/home"
print(os.path.join(path, "User/Desktop", "file.txt"))
Example 2: python get base directory
import os
os.path.dirname(os.path.realpath(__file__))
Example 3: python join paths
import os
path = os.path.join('/var/www/public_html', './app/', ".\\my_file.json")
print(path)
Example 4: os.path module in python 3
import os.path