python获取绝对路径复制文件
import shutil import sys import os def cur_file_dir(): path = sys.path[0] if os.path.isdir(path): return path elif os.path.isfile(path): return os.path.dirname(path) def path(p): return os.path.normpath(os.path.join(cur_file_dir(), p)) shutil.copyfile(path("22.txt"), path("33.txt")) #file = ["xl_decrypt.cpp", "xl_decrypt.h", "xl_lzma.h", "xl_lzma.cpp", "xl_machine.cpp", \ "xl_machine.h"] #for one in file: s = "..\\ServerGui\\" + one #shutil.copyfile(path(one), path(s))
浙公网安备 33010602011771号