summaryrefslogtreecommitdiff
path: root/keyword/common/customlibrary/Library/fileOperations.py
diff options
context:
space:
mode:
Diffstat (limited to 'keyword/common/customlibrary/Library/fileOperations.py')
-rw-r--r--keyword/common/customlibrary/Library/fileOperations.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/keyword/common/customlibrary/Library/fileOperations.py b/keyword/common/customlibrary/Library/fileOperations.py
new file mode 100644
index 0000000..4029e26
--- /dev/null
+++ b/keyword/common/customlibrary/Library/fileOperations.py
@@ -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)
+