Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- #coding utf8
- import sys
- import os
- import re
- def readJson() :
- curDir = "./"
- pattern = re.compile("^introduce_[\d]+.json$")
- for dir in os.listdir(curDir) :
- if pattern.match(dir) == None:
- continue
- json = open(dir, "r")
- jsonContent = formatJson(json)
- json.close()
- newjson = open('../jsons/'+ os.path.splitext(dir)[0]+'.json', "a")
- newjson.write(jsonContent)
- newjson.close( )
- def formatJson(json) :
- pattern = re.compile("\"introduce\": \"")
- jsonContent = ""
- for line in json:
- if pattern.match(line) != None:
- line = re.sub(pattern, "\"introduce\": \" ", line)
- pattern = re.compile("<br>")
- line = pattern.sub('<br> ', line)
- pattern = re.compile("<br> \"")
- line = pattern.sub('<br>', line)
- jsonContent += line
- return jsonContent
- if __name__ == '__main__':
- readJson()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement