初始化
This commit is contained in:
24
utils/files.py
Normal file
24
utils/files.py
Normal 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')
|
||||
Reference in New Issue
Block a user