导入导出功能自动化,对象txt格式导入导出,策略txt和json格式导入,txt格式导出
This commit is contained in:
26
04-CustomLibrary/Library/fileOperations.py
Normal file
26
04-CustomLibrary/Library/fileOperations.py
Normal file
@@ -0,0 +1,26 @@
|
||||
def CountLines(fname):
|
||||
count = 0
|
||||
with open(fname, 'rb') as f:
|
||||
for file_line in f:
|
||||
file_line = file_line.strip()
|
||||
# print(file_line)
|
||||
# 空行
|
||||
if file_line == b'':
|
||||
pass
|
||||
|
||||
# 注释 # 开头
|
||||
elif file_line.startswith(b'-->'):
|
||||
pass
|
||||
|
||||
# 代码
|
||||
else:
|
||||
count += 1
|
||||
print(fname + '----', count)
|
||||
# 单个文件行数
|
||||
# print(fname,'----count:',count)
|
||||
return count
|
||||
def WriteBinary(response,path1):
|
||||
with open(path1,"wb") as f2:
|
||||
strb = response
|
||||
f2.write(strb)
|
||||
|
||||
Reference in New Issue
Block a user