Page 47 - Python Cơ Bản
P. 47
f2 = open('access_log', 'a+')
f2.write('Attack detected')
ɇɹRK JMPI чɪ QЮ
7EY OLM LSɧR XϴX GɨG XLES XɨG чМG KLM JMPI XLɳ KМM TLRK
XLиG close() чВ чɹRK JMPI чɪ QЮ :ɴ Hд
f1.close()
f2.close()
ɇФM XɱR JMPI
7м HдRK TLRK XLиG os.rename(old, new) чВ чФM XɱR
QШX JMPI :ɴ Hд
import os
os.rename('test.txt', 'test_new.txt')
<ɹE JMPI
7м HдRK TLRK XLиG os.remove(file) чВ \ɹE QШX JMPI