Python
LuckyJoey
见贤思齐焉,见不贤而内自省也
展开
-
Python自定义生成egret中的xxx.res.json文件
import reimport sysimport os#遍历文件def ErgodicFiles(path,resjsonPath,urlPath): print(path) fileGroupsList=[] fileResourcesList=[] for filename in os.listdir(path): strs = filename.split(".") keyName = strs[0] g.原创 2020-10-29 14:53:09 · 254 阅读 · 0 评论 -
指定文件生成crc32码写入到指定后缀文件里
#生成CRC32校验码,作为资源版本号,在资源配置json文件写入from ctypes import * import binascii def getFileCRC(_path): try: blocksize = 1024 * 64 f = open(_path,"rb") str = f.read(blocksize) crc = 0 while len(str) != 0: .原创 2020-10-10 16:38:33 · 545 阅读 · 1 评论 -
egret项目,通过gulp,根据输入资源类型,按文件夹名称作为group名称,自动生成xxx.res.json文件
gulpfile.jsvar gulp = require('gulp'); var fs = require("fs");//type 角色0,动画1var type=1;var resPath,dirPath,resName;function SetTypePath(n){ switch(n) { //角色 case 0: resPath="../resource/Arts/Animals/xxxA/"; dirPath="Arts/Animals/xx...原创 2020-09-27 15:50:46 · 238 阅读 · 0 评论 -
python 根据输入,修改文件里面内容
import reimport syspath = "E:/SvnProjects/xxx/xxx/template/web/index.html"#修改index.html文件,设置网络类型def updatefiles(netModel): f = open(path,'r') alllines=f.readlines() f.close() ff = open(path,'w') for line in alllines: if re.search('var ServerNe.原创 2020-09-25 14:34:57 · 244 阅读 · 0 评论 -
通过openpyxl (Python)读取.txt文本,写入.xlsx(Excel)
import openpyxldef read_txt(): with open(r'DKBanword.txt','r',encoding='utf-8') as f:#打开txt文件 data = f.read().replace('\n', '') #遍历txt文件内容存放到列表 contents = data.split('、') #过滤重复字段、空字符字段 newContents=[] for c in contents: if c not in newCon.原创 2020-08-27 14:54:09 · 2396 阅读 · 1 评论 -
Python入门之os.walk()方法
os.walk方法,主要用来遍历一个目录内各个子目录和子文件。os.walk(top, topdown=True, onerror=None, followlinks=False) 可以得到一个三元tupple(dirpath,dirnames,filenames),第一个为起始路径,第二个为起始路径下的文件夹,第三个是起始路径下的文件。dirpath是一个s...转载 2019-06-11 11:06:56 · 5551 阅读 · 0 评论 -
python:open/文件操作
转自from:https://www.cnblogs.com/dkblog/archive/2011/02/24/1980651.htmlopen/文件操作f=open('/tmp/hello','w')#open(路径+文件名,读写模式)#读写模式:r只读,r+读写,w新建(会覆盖原有文件),a追加,b二进制文件.常用模式如:'rb','wb','r+b'等等读写模式的类型有:...转载 2019-04-25 14:58:10 · 130 阅读 · 0 评论 -
Python中常出现TabError: inconsistent use of tabs and spaces in indentation的原因
TabError: inconsistent use of tabs and spaces in indentationwin10平台用的Notepad++编辑,正常用tab键,报这个错是因为这都是看似空格实则没有空格引起的。解决方法是敲真空格,或者设置编辑器首选项或者换其他编辑器。...原创 2019-04-25 14:24:41 · 2986 阅读 · 0 评论 -
python class和class(object)用法区别
原博:https://www.cnblogs.com/liulipeng/p/7069004.html# -*- coding: utf-8 -*-# 经典类或者旧试类class A: passa = A()# 新式类class B(object): passb = B()# python2不支持# print(A.__class__)p...转载 2019-04-09 15:02:19 · 1229 阅读 · 0 评论 -
解析Python中的yield关键字
原文:https://www.cnblogs.com/zhenlingcn/p/8337788.html前言python中有一个非常有用的语法叫做生成器,所利用到的关键字就是yield。有效利用生成器这个工具可以有效地节约系统资源,避免不必要的内存占用。一段代码def fun():for i in range(20): x=yield i print('good...转载 2019-04-01 17:13:36 · 82 阅读 · 0 评论