Python实现文件的拷贝

可用于windows或者linux系统

拷贝文件的同时可以重命名

#!/usr/bin/env python
#-*- coding: utf-8 -*-
import os
import os.path
from shutil import copy

print("在linux系统中输入文件路径必须加双引号,windows系统不用此操作 ")

source = input("Enter source file with full path: ")
target = input("Enter target file with full path: ")

copy(source, target)
#try:
#   copyfile(source, target)
#except IOError as e:
#   print("Unable to copy file. %s" % e)
#   exit(1)
#except:
#   print("Unexpected error:", sys.exc_info())
#   exit(1)

print("\nFile copy done!\n")

猜你喜欢

转载自blog.csdn.net/sinat_37343534/article/details/103206926