I want to know the difference between the two, just like the title. The result of executing the code is
print(_file__)
print(os.path.dirname(__file__))
print(os.getcwd())
C:/Users/Desktop/pythonedit/API/api df.py
C:/Users/Desktop/pythonedit/API
C:\Users\Desktop\pythonedit\API
I know the location and name of the file that the first one ran. What is the difference between os.path.dirname(file) and os.getcwd()?
python
If you have /A/B/c.py, /A > Python B/c.py.
At this time, 1 is /A2 is /A/B
© 2024 OneMinuteCode. All rights reserved.