SoFunction
Updated on 2024-10-30

Python 3 ways to get the current path

1、 methodologies

# -*- coding: utf-8 -*-
# !/usr/bin/python

import os
import sys

current_directory = ((__file__))

print(current_directory)

Output:

Alt

2、 methodologies

# -*- coding: utf-8 -*-
# !/usr/bin/python

import os
import sys

root_path = ((current_directory) +  + ".")
(root_path)

print([0])

Output:

Alt

3、 methodologies

currentPath = ().replace('\\','/')    # Get current path
print(currentPath)

Output:

Alt

to this article on Python to get the current path of the three ways to this article, more related to Python to get the current path of content please search my previous posts or continue to browse the following related articles I hope you will support me in the future more!