|
自学了 Python 几天,一直想亲自动手实践一番,于是写了一个与字符串提取有关的小脚本,与 AutoRclone 或 gclone 搭配食用,提取 accounts 目录下 json 文件的文件名和邮箱,便于查询和添加到 Google groups
使用前请先安装 Python3
[ol]import reimport sysimport os,glob# 定义目录:目录下有多个文件需要处理,为 accounts 目录的路径,例如: path = 'D://AutoRclone//accounts'path = 'path//to//your//accounts'# 定义输出文件,路径可自定义,例如 fout = open("D://AutoRclone//accounts//res.txt", 'w')fout = open("res.txt", 'w')os.chdir(path)fout.write("用户名和邮箱(便于查询)\n")for filename in os.listdir() : fs = open(filename, 'r+') fout.write("文件名:" + filename + '\n') for line in fs.readlines(): mylist_1 = line.split(":") if mylist_1[0] == " "client_email"" : mylist_2 = mylist_1[1].split(""") fout.write(mylist_2[1] + '\n')fout.write("\n\n")fout.write("邮箱(便于添加到 Google group)\n")for filename in os.listdir() : fs = open(filename, 'r+') for line in fs.readlines(): mylist_1 = line.split(":") if mylist_1[0] == " "client_email"" : mylist_2 = mylist_1[1].split(""") fout.write(mylist_2[1] + '\n')fout.write('\n')fout.close()[/ol]复制代码
项目地址:https://github.com/Sheldonsix/A-python-script-of-AutoRclone-or-gclone
参考教程:https://blog.csdn.net/lavorange/article/details/41647091 |
|