반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- google apps script
- numpy
- Tkinter
- Java
- GIT
- math
- array
- django
- Mac
- 파이썬
- Github
- Python
- hive
- PostgreSQL
- PySpark
- c#
- Google Spreadsheet
- list
- Kotlin
- Redshift
- matplotlib
- Excel
- SQL
- Google Excel
- Apache
- dataframe
- gas
- PANDAS
- string
Archives
- Today
- Total
목록__FILE__ (1)
달나라 노트
Python Basic : __file__ (실행중인 python file의 경로 반환)
python을 실행하면 기본적으로 설정되는 변수들이 있습니다. 그 중에서 __file__은 현재 python file이 존재하는 경로를 반환해줍니다. print(__file__) -- Result /User/documents/code/test.py 만약 위 print구문이 적힌 파일이 /User/documents/code/test.py라는 경로에 존재하면 위 예시처럼 해당 파일의 절대 경로를 반환해줍니다. import os print (os.path.dirname(__file__)) -- Result /User/documents/code os library를 이용하여 파일 이름 없이 경로만 얻을 수도 있습니다.
Python/Python Basic
2021. 6. 26. 18:29