Python脚本备份
#!/usr/bin/python3 # -*- coding:utf-8 -*- # 保证源程序可以输入汉字 print bool([]) # 任何为零的数字或空集(空列表、空元组和空字典等)均为False radius = input(u"输入半径: "); radius_float = float(radius); area=radius_float**2*3.1415926; # **是平方运算,pow()也可以执行平方运算
print u'面积:%f'%(area)
# coding:utf-8 import os import re import shutil from subprocess import Popen, PIPE safe_imgs_path = os.path.dirname(__file__) destination_path = safe_imgs_path.split('GlobalRobot')[0] + 'GlobalApp' proj_path = destination_path + '/GlobalApp.xcodeproj/project.pbxproj' def getBundleId(): pattern = 'PRODUCT_BUNDLE_IDENTIFIER = (.*);' bundle_id = None with open(proj_path) as f: s = ''.join(f.readlines()) res = re.findall(pattern, s) if len(res): bundle_id = res[0] f.close() return bundle_id def handle_safeImage(): bundle_id = getBundleId() if bundle_id: cmd = 'cp {img_path}/{img_name}.jpg {des_path}/{des_name}.jpg'.format(img_path=safe_imgs_path, img_name=bundle_id, des_path=destination_path, des_name='yw_1222_07e8') Popen(cmd, shell=True) def change_robotCode(): bundle_id = getBundleId(); normal_name='a1myR6pZui3'; test_name='a1wYaPBqf6g'; print bundle_id; root_path=safe_imgs_path.split('GlobalRobot')[0]; logidPath = root_path + 'GlobalRobot/GLBRobot/GLBConfig/GLBRobotConfig.bundle/GLBRobotLogicIdMap.json' router_path = root_path + 'GlobalRobot/GLBRobot/GLBConfig/GLBRobotConfig.bundle/GLBRobotRouteTable.json' if bundle_id == 'com.eco.global.app': changeDX5ClassName(logidPath,normal_name,test_name) changeDX5ClassName(router_path,normal_name,test_name) elif bundle_id =='com.vivien.demo': changeDX5ClassName(logidPath,test_name,normal_name) changeDX5ClassName(router_path, test_name, normal_name) return; def changeDX5ClassName(fileName,toName="a1myR6pZui3",from_name='a1wYaPBqf6g'): print 'toName'+toName+' ,fromName:'+from_name ; file_path = fileName; backup_path = file_path + '.bak' if not os.path.exists(backup_path): shutil.copy2(file_path, backup_path) with open(file_path, mode='r') as fr, open(backup_path, mode='w') as fw: for line in fr: re_sub_list = re.sub(from_name, toName, line) # 这里用re.sub进行替换后放入 re_sub_list中 print('re_sub_list'+re_sub_list); fw.writelines(re_sub_list) # 将列表中的每一行进行写入。writelines是将序列对象中的每一行进行写入。 os.remove(file_path); os.rename(backup_path, file_path); if __name__ == '__main__': print "==============================开始替换安全图片==============================" handle_safeImage() print "==============================完成替换安全图片==============================" print "==============================开始更换DX5 Class==============================" change_robotCode() print "==============================完成更换DX5 Class=============================="
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!