python - os.rename() move the directory but does not removed the old one. it worked like copy -


I am running on 'C: \' and copying 'Y: in:' is it important ?

My code:

  def Rename (src, dst): Try: if os.path.exists (dst): os.unlink (dst) os Renames (src, dst) Returns 0 except OSError, print: Print ("" '% s' to rename '% s':% (src, dst, os.strerror (err.errno)) < If you have a different file system, you would have to go to  shutil.move (src, dst), or    

should use

to:

If the destination is on the existing file system, then os.rename () is used. Otherwise, src is copied (using shutil.copy2 ()) and then DST.

Comments

Popular posts from this blog

ruby on rails - How to avoid ActionController::InvalidCrossOriginRequest exception? -

Selenium IDE Conditional Statements -

How to edit the second line in text file using batch? -