當前位置:編程學習大全網 - 網站源碼 - 求Python代碼

求Python代碼

#!/usr/bin/env python

#coding=gbk

import os

import sys

import shutil

DIRNAME = "E:\\Program Files\\ArcGis\\"#目錄名稱

TARGET = "C:\\"#移動文件的目標目錄

ISFILE = "file.txt"

if os.path.isfile(DIRNAME+ISFILE):

try:

i = raw_input("Move file %s ? [Y/N] " %ISFILE)

if 'y'==i.lower():

shutil.move(DIRNAME+ISFILE,TARGET+ISFILE)

elif 'n'==i.lower():

pass

else:

print "Please input 'Y' or 'N'"

except KeyboardInterrupt:# catch CTRL-C

print "exit!"

sys.exit(1)

else:

print "File %s%s doesn't exists !" %(DIRNAME+ISFILE)

  • 上一篇:索尼克全明星賽車變形手柄怎麽用
  • 下一篇:Vbs wscript.arguments缺少對象字符串“Start”。
  • copyright 2024編程學習大全網