1 Star 1 Fork 0

niann/easy-help

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
config.py 784 Bytes
一键复制 编辑 原始数据 按行查看 历史
年年 提交于 2024-02-03 19:57 +08:00 . version1.0
import os,sys
"""
@aurhor niann
获取配置文件中的key
"""
def get_key():
try:
key_conf = open('./conf/easy.conf',"r")
text = key_conf.read()
if len(text) == 0:
raise Exception("./conf/easy.conf is null")
key = eval(text).get("key")
if key == None:
print("NotFound key Please set key: easy config [your key]")
return
return key
except FileNotFoundError:
open("./conf/easy.conf",'x')
print("NotFound easy.conf")
'''
@author
TODO 设置key
'''
def set_key(key):
if not os.path.exists("./conf"):
os.makedirs("./conf")
file = open("./conf/easy.conf","w")
file.write('''{
"type":"alibaba",
"key":"'''+key+'''"\n}''')
print(key)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/coding_niann/easy-help.git
git@gitee.com:coding_niann/easy-help.git
coding_niann
easy-help
easy-help
master

搜索帮助