文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>python copy file

python copy file

时间:2010-09-05  来源:lexus

<code>import shutil
shutil.copy2('/dir/file.ext', '/new/dir/newname.ext')
</code>

or

<code>shutil.copy2('/dir/file.ext', '/new/dir')
</code>

copy2 is also often useful, it preserves the original modification and access info (mtime and atime) in the file metadata.

 

 

 

 

 

http://stackoverflow.com/questions/123198/how-do-i-copy-a-file-in-python

  49 down vote accepted

shutil has many methods you can use. One of which is:

<code>copyfile(src, dst)
</code>

Copy the contents of the file named src to a file named dst. The destination location must be writable; otherwise, an IOError exception will be raised. If dst already exists, it will be replaced. Special files such as character or block devices and pipes cannot be copied with this function. src and dst are path names given as strings. 

相关阅读 更多 +
排行榜 更多 +
找茬脑洞的世界安卓版

找茬脑洞的世界安卓版

休闲益智 下载
滑板英雄跑酷2手游

滑板英雄跑酷2手游

休闲益智 下载
披萨对对看下载

披萨对对看下载

休闲益智 下载