Page 49 - Python Cơ Bản
P. 49

ɇМG RШM HYRK XLš QдG





          7м HдRK TLš˜RK 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 TLš˜RK 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
   44   45   46   47   48   49   50   51   52   53   54