forked from veip007/hj
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ssr.py
23 lines (19 loc) · 986 Bytes
/
ssr.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# coding:utf-8
import base64
import os
source_files_path = r'/root/ssr' # txt文件绝对路径 ex: /root/tmp/原始文件
out_file_path = r'/www/wwwroot/www.lefu.men/' # 成品文件绝对路径(提前创建好) ex: /root/result
files_path = os.listdir(source_files_path)
base64_tmp = []
for txt_file in files_path:
if txt_file.endswith('.txt'):
with open(os.path.join(source_files_path, txt_file), 'r', encoding='utf-8') as fn:
_txt = fn.read()
_txt_jiemi = base64.b64decode(_txt.encode('utf-8')).decode('utf-8')
base64_tmp.append(_txt_jiemi.strip())
with open(os.path.join(out_file_path, 'ssr.txt'), 'a+', encoding='utf-8') as fn:
fn.write('\n'.join(base64_tmp))
#with open(os.path.join(out_file_path, 'ssr_base64.txt'), 'a+', encoding='utf-8') as fn:
# _text = '\n'.join(base64_tmp)
# fn.write(base64.b64encode(_text.encode('utf-8')).decode('utf-8'))
#以上注释为不生成base64格式的txt