-
<PYTHON>[twisted.filepath.FilePath]Flower in my dev/Python 2015. 7. 14. 16:06
[filepath.FilePath]
파이썬에서 사용하는 file을 확장했다고 봐야할듯..
대상파일이 없어도 인스턴스를 생성할 수 있다.
유용한 함수들
- child(something) : something의 결대경로 표시(FilePath형)
- children() : 하위 파일 또는 디렉토리
- touch() : 파일 생성
- makedirs() : 파일 생성(디렉토리)
- create() : 파일 생성(실행)
- remove() : 삭제
- chmod(mode) : mode(int)의 값에 맞게 권한변경
- basename() : 이름
- dirname() : 경로
- realpath() : 경로/이름
- getAccessTime() : 마지막 접근 시간
- exists() : 실제 존내 유무(retrun True or False)
- isdir() : 디렉토리 확인(retrun True or False)
- isfile() : 파일 확인(retrun True or False)
- islink() : 링크 확인(retrun True or False)
- listdir() : 하위 파일 또는 디렉토리 리스트로 반환
- copyTo(dst) : dst에 파일 복사
- moveTo(dst) : dst로 파일 이동
12345678910111213141516171819202122232425262728293031323334from twisted.python.filepath import FilePathp = FilePath('test')print pprint p.child('test')print p.children()print p.listdir()print p.basename()print p.dirname()print p.realpath()new = FilePath('flower')new.makedirs()print new.exists():print new.isdir():print new.isfile():print new.islink():cm = FilePath('test.txt')print cm.isfile()cm.moveTo(new.child('ok.txt'))print cm.isfile()cm.touch()cm.copyTo(new.child('ko.txt'))print new.children()print cm.isfile()cs 'Flower in my dev > Python' 카테고리의 다른 글
<PYTHON>[socket:TCP] (0) 2015.07.28 <PYTHON>[socket] (0) 2015.07.28 <PYTHON>[itertools] (0) 2015.07.13 <PYTHON>[binascii] (0) 2015.07.10 <PYTHON>[dpkt] (0) 2015.07.10