Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

วิธีหา Full Path ของไดเรกทอรีไฟล์ปัจจุบันใน Python

ใช้ os.path.realpath(__file__) หาพาธเต็มของไฟล์ปัจจุบัน

ตัวอย่าง

>>> import os
>>> print(os.path.realpath(__file__))
/home/ayush/qna/path.py