How to move a file?

后端 未结 9 1843
夕颜
夕颜 2020-11-22 01:07

I looked into the Python os interface, but was unable to locate a method to move a file. How would I do the equivalent of $ mv ... in Python?

&g         


        
9条回答
  •  天涯浪人
    2020-11-22 01:29

    Based on the answer described here, using subprocess is another option.

    Something like this:

    subprocess.call("mv %s %s" % (source_files, destination_folder), shell=True)
    

    I am curious to know the pro's and con's of this method compared to shutil. Since in my case I am already using subprocess for other reasons and it seems to work I am inclined to stick with it.

    Is it system dependent maybe?

提交回复
热议问题