Files
medical-mall/temp.py

30 lines
1.3 KiB
Python
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import json
import codecs
import re
file_path = r'd:\\骅锋\\mall\\pages.json'
with codecs.open(file_path, 'r', 'utf-8') as f:
text = f.read()
target = r'(\{\s*\
path\\s*:\s*\pages/mall/admin/homePage/index\[\w\W]*?\})'
new_block = ''',{
\path\: \pages/mall/admin/userCenter/index\,
\style\: {
\navigationBarTitleText\: \个人中心\,
\navigationStyle\: \custom\
}
}'''
def rcb(match):
return match.group(1) + new_block
new_text = re.sub(target, rcb, text)
if new_text != text:
with codecs.open(file_path, 'w', 'utf-8') as f:
f.write(new_text)
print('Updated!')
else:
print('No changes!')