Update 在线V4源优选.py

This commit is contained in:
frxz751113
2024-08-16 09:28:50 +08:00
committed by GitHub
parent 3363db4d8a
commit 7443754ac7
+2 -2
View File
@@ -43,13 +43,13 @@ for line in lines:
# 如果没有"$",则直接添加到列表,确保以换行符结束 # 如果没有"$",则直接添加到列表,确保以换行符结束
processed_lines.append(line.rstrip() + '\n') processed_lines.append(line.rstrip() + '\n')
# 将处理后的内容写入新文件 # 将处理后的内容写入新文件
with codecs.open('3.txt', 'w', 'utf-8') as file: with codecs.open('源.txt', 'w', 'utf-8') as file:
file.writelines(processed_lines) file.writelines(processed_lines)
################################################################################################### ###################################################################################################
################################################################################################### ###################################################################################################
# 使用with语句打开输入文件进行读取 # 使用with语句打开输入文件进行读取
with open("3.txt", 'r', encoding='utf-8') as file: with open("源.txt", 'r', encoding='utf-8') as file:
lines = file.readlines() lines = file.readlines()
# 使用列表推导式过滤行 # 使用列表推导式过滤行
filtered_lines = [ filtered_lines = [