Ai
1 Star 0 Fork 0

沉冰浮水/水水的旧代码合集

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
function.py 1.46 KB
一键复制 编辑 原始数据 按行查看 历史
沉冰浮水 提交于 2023-04-07 12:17 +08:00 . up. py 按行分析文件
import os
import sys
import json
def loadConfig(dir=""):
config_info = {}
# 如果 dir 为空,则使用当前目录
if(dir == ""):
dir = os.getcwd()
# 拼接 dir + "/config.json" 文件路径
cfg_path = "%s/config.json" % dir
if os.path.exists("%s/config.json" % dir):
with open(cfg_path, 'rb') as f:
config_info = json.loads(f.read())
# 如果存在 ext 字段,判断是否为 . 开头,如果不是,则添加 . 开头
if("ext" in config_info):
if(config_info["ext"][0] != "."):
config_info["ext"] = "." + config_info["ext"]
# 如果不存在 outfile 字段
if("outfile" not in config_info):
config_info["outfile"] = "%s/out%s" % (
config_info["pwd"], config_info["ext"])
if ("tpl" not in config_info):
config_info["tpl"] = "#str#"
return config_info
def readTxtLines(txt_file):
list = []
with open(txt_file, 'r', encoding='UTF-8') as f:
for line in f:
list.append(line.strip())
list.sort()
return list
def isItemInList(list, item, field=""):
for i in list:
if(field == ""):
if(i == item):
return True
else:
if(i[field] == item):
return True
return False
def isSameFile(file1, file2):
# 统一分隔符
file1 = file1.replace("\\", "/")
file2 = file2.replace("\\", "/")
if(file1 == file2):
return True
return False
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wdssmq/StaleCode.git
git@gitee.com:wdssmq/StaleCode.git
wdssmq
StaleCode
水水的旧代码合集
master

搜索帮助