int면 int, string이면 string 같은 타입은 이미 내장되어 있는 메소드가 있다
그게 어떤 것들이 있는지 메소드의 리스트를 출력하는 방법이다.
file=open("textfile.txt", 'r')
print(type(file))
print(dir(file))
Out
<class '_io.TextIOWrapper'>
['_CHUNK_SIZE', '__class__', '__del__', '__delattr__', '__dict__', '__dir__', '__doc__', '__enter__', '__eq__', '__exit__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__lt__', '__ne__', '__new__', '__next__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '_checkClosed', '_checkReadable', '_checkSeekable', '_checkWritable', '_finalizing', 'buffer', 'close', 'closed', 'detach', 'encoding', 'errors', 'fileno', 'flush', 'isatty', 'line_buffering', 'mode', 'name', 'newlines', 'read', 'readable', 'readline', 'readlines', 'reconfigure', 'seek', 'seekable', 'tell', 'truncate', 'writable', 'write', 'write_through', 'writelines']
이렇게 출력된다
에서 소개한 read 메소드도 여기에 들어있는 것을 확인할 수 있다
'개발 > Python' 카테고리의 다른 글
[Python] Guardian Pattern(가디언 패턴) (0) | 2021.08.06 |
---|---|
[Python] Short Circuiting / Short Circuit Evaluation(단축평가, 단락평가) (0) | 2021.08.06 |
[Python] 리스트 생성/만드는 방법 (0) | 2021.08.04 |
[Python] 파일 열기, 읽기 (0) | 2021.08.03 |
[Python] 개행(newline) (0) | 2021.08.02 |