파일 열기

>>> f = open('workfile', 'w')

>>> print(f)
<open file 'workfile', mode 'w' at 80a0960>

파일 쓰기

>>> f.write('This is a test\n')

>>> value = ('the answer', 42)

>>> s = str(value)

>>> f.write(s)

파일 닫기

>>> f.close()

>>> f.read()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ValueError: I/O operation on closed file

results matching ""

    No results matching ""