29 lines
716 B
Python
29 lines
716 B
Python
import json
|
|
import os
|
|
|
|
|
|
def write_info(file_name, file_info):
|
|
dir = os.path.dirname(file_name)
|
|
if not os.path.exists(dir):
|
|
os.makedirs(dir)
|
|
with open('{}.json'.format(file_name), 'w', encoding='UTF-8') as fp:
|
|
json.dump(file_info, fp, indent=4, sort_keys=False)
|
|
fp.close()
|
|
|
|
|
|
def read_json(file_path):
|
|
with open(file_path, 'r') as f:
|
|
data = json.load(f)
|
|
f.close()
|
|
return data
|
|
|
|
|
|
if __name__ == "__main__":
|
|
path = os.path.abspath(os.path.dirname(__file__))
|
|
print(path)
|
|
# write_info('', dict(report_data))
|
|
# read_json('d://report.json')
|
|
# s = '/group1/628740635893760/ori/images/7 (1).png'
|
|
# s1 = s.replace('images', 'labels')
|
|
# print(s[2])
|