-
-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
添加IO流函数 #80
添加IO流函数 #80
Conversation
更新IO流函数
更新IO流函数配置文件
OlivOS/userModule/IOStream.py
Outdated
os.mkdir("plugin/tmp/Input/input_data") | ||
if not os.path.exists(data_path): | ||
init_data = {} | ||
with open(data_path,"w",encoding="utf-8") as file: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应该将文件打开模式由"w"改成"wb",否则在读取的时候会报TypeError的错误提示
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
麻了草,我忘了改读取模式了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改,反正离合并还远,我正在做另一个开发
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#思考
没怎么用过pr,原项目修改后怎么更新到这个pr里
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
通常来说,只要你的pr开放,被合入的分支中任何提交都会被补充进来
with open(cache_path, "w", encoding='utf8') as f: | ||
pickle.dump(cache_data, f, indent=4, ensure_ascii=False) | ||
return | ||
#新序列不合法,结束输入流,删除缓存数据 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if dealt_time > max_time: os.rename(cache_path, \
"plugin/tmp/Input/input_data/{}_expired.pickle".format(cache_file_name))
group = str(self.data.group_id) | ||
data_path = 'plugin/tmp/Input/{}_input_log.pickle'.format(plugin_name) | ||
if not os.path.exists("plugin/tmp/Input"): #检验数据文件与目录是否存在 | ||
os.mkdir("plugin/tmp/Input") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
快考虑使用os.makedirs()函数,这样可以级联创建需要的目录,更加方便!!!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
本来是有考虑的()
但是因为是在原先的代码上改,就没想改x
所以暂且就这样了
import pickle | ||
import time | ||
import uuid | ||
from .. import API |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
baka!
具体内容见开头注释