1. 程式人生 > >python更新遊戲程序

python更新遊戲程序

zip move back ack tdi pts lena walk env

#!/usr/bin/env python #coding:utf-8 import os import shutil import zipfile dm_path = ‘/data/bz-tw-and‘ script_path = os.getcwd() new_dm_dir = script_path+‘/bz_new/scripts‘ after_zip = ‘.zip‘ for (root,dirs,filename) in os.walk(script_path): for file in filename: if file[-4:] == after_zip: zip_package = os.path.join(root,file) z = zipfile.ZipFile(zip_package,‘r‘) z.extractall(script_path+‘bz_new‘) z.close for qu_name in os.listdir(dm_path): backup_dm = dm_path+‘/‘+qu_name+‘/‘+‘_scripts‘ now_dm = dm_path+‘/‘+qu_name+‘/‘+‘scripts‘ if os.path.exists(backup_dm): shutil.rmtree(backup_dm) os.rename(now_dm,backup_dm) else: os.rename(now_dm,backup_dm) shutil.copytree(new_dm_dir,now_dm) os.remove(now_dm+‘/Config.lua‘) shutil.copyfile(dm_path+‘/‘+qu_name+‘/Config.lua‘,now_dm+‘/Config.lua‘)

python更新遊戲程序