初始化

This commit is contained in:
2026-04-10 10:57:44 +08:00
parent ec6e7573de
commit a19a468298
70 changed files with 5676 additions and 0 deletions

24
utils/files.py Normal file
View File

@@ -0,0 +1,24 @@
def save_line(filepath, text):
with open(filepath, 'a+', encoding='utf-8') as f:
f.writelines(text+'\n')
def load_lines(filepath):
with open(filepath, 'r', encoding='utf-8') as f:
text = f.read()
return text.split('\n')
def save_text(filepath, text):
with open(filepath, 'w', encoding='utf-8') as f:
f.write(text)
def add_text(filepath, text):
with open(filepath, 'a+', encoding='utf-8') as f:
f.writelines(text+'\n')
def save_list(filepath, lists: list):
with open(filepath, 'w', encoding='utf-8') as f:
f.write('\n'.join(lists))
def add_list(filepath, lists: list):
with open(filepath, 'a+', encoding='utf-8') as f:
f.write('\n'.join(lists)+'\n')