반응형
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
- matplotlib
- google apps script
- Apache
- string
- PySpark
- Excel
- Python
- Google Excel
- GIT
- Java
- PANDAS
- PostgreSQL
- math
- Kotlin
- hive
- list
- numpy
- Redshift
- SQL
- gas
- Tkinter
- Google Spreadsheet
- django
- dataframe
- 파이썬
- Mac
- array
- c#
- Github
Archives
- Today
- Total
달나라 노트
Python ftplib : pwd (print working directory) & cwd (change working directory) 본문
Python/Python ftplib
Python ftplib : pwd (print working directory) & cwd (change working directory)
CosmosProject 2021. 2. 2. 21:18728x90
반응형
import ftplib
s3_host = '11.111.111.111'
s3_user_id = 'user_1'
s3_user_password = 'pw_1'
ftp = ftplib.FTP()
ftp.encoding = 'utf-8'
ftp.connect(s3_host) # connect to s3
ftp.login(s3_user_id, s3_user_password) # login to s3
# show current directory
print('Current directory :', ftp.pwd())
ftp.quit() # quit s3
- Output
Current directory : /
ftplib의 pwd는 현재 디렉토리를 출력해줍니다.
로그인한 후의 Directory는 root directory이므로 그냥 /만 출력됩니다.
import ftplib
s3_host = '11.111.111.111'
s3_user_id = 'user_1'
s3_user_password = 'pw_1'
ftp = ftplib.FTP()
ftp.encoding = 'utf-8'
ftp.connect(s3_host) # connect to s3
ftp.login(s3_user_id, s3_user_password) # login to s3
ftp.cwd('/test1/test2/')
print('Current directory :', ftp.pwd())
ftp.quit() # quit s3
- Output
Current directory : /test1/test2/
cwd는 디렉토리 위치를 변경해줍니다.
디렉토리 변경 후 pwd를 이용해 현재 디렉토리를 출력하면 변경된 디렉토리로 출력된 것을 알 수 있습니다.
728x90
반응형
'Python > Python ftplib' 카테고리의 다른 글
Python ftplib : storbinary (upload file to s3) & delete (delete file) (0) | 2021.02.02 |
---|---|
Python ftplib : nlst (Directory 속 file list) (0) | 2021.02.02 |
Python ftplib : mkd (make directory) & rmd (remove directory) (0) | 2021.02.02 |
Python ftplib : login (0) | 2021.02.02 |
Comments