Page 49 - Python Cơ Bản
P. 49
ɇМG RШM HYRK XL QдG
7м HдRK TLRK XLиG os.listdir(dir) чВ Pϴ] HERL WɨGL
XϼT XMR XL QдG GжE XL QдG dir /LM KМM WЌ XVϲ ZА QШX
QϲRK HERL WɨGL GɨG XϼT XMR XL QдG :ɴ Hд
import os
allfiles = os.listdir('/root/downloads')
print allfiles
1SHYPI os
1SHYPI os Pɧ QШX QSHYPI Gɹ RLMАY TLRK XLиG LоY ɴGL
XVSRK ZMЖG PɧQ ZMЖG ZЪM GɨG JMPI Zɧ HMVIGXSV] RL
os.chdir(path) чФM XL QдG LMЖR LɧRL
os.getcwd() XVϲ ZА XL QдG LMЖR LɧRL
os.chmod(path, mode) ',13( QШX чЬRK HϺR
os.chown(path, uid, gid) ',3;2 QШX чЬRK HϺR
os.makedirs(path[, mode]) XϰS чЬRK HϺR Gɹ
VIGYVWMZI