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

runtime error - Cannot find an overload for op_subtraction when subtracting datetime from datetime in powershell -

javascript - Backbone pushState routes -

jsp - No mapping found for HTTP request with URI with annotation config Spring MVC and Jetty -