Files
spider/utils/files.py
2026-04-10 10:57:44 +08:00

25 lines
730 B
Python

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')