Method 1.
import sys print()
Get a list of the file's current absolute path strings.
['D:/pycharm/PracticeProject/']
Method 2.
import os print(()) print(()) print(((),()[1])) D:\pycharm\PracticeProject ['.idea', ''] D:\pycharm\PracticeProject\
() Get the current working path, the path does not include the current filename.
() Get a list of file and folder names under the current path
The last step of splicing the paths gives you a string of absolute paths to the current file
Attention:Method 1 and Method 2 a slash and a backslash
The above two methods to get the current absolute path of a file in python3 is all that I have shared with you, I hope to give you a reference, and I hope you will support me more.