Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
yuweiwan authored Oct 12, 2023
1 parent 8cc4367 commit 7c3f75b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# @Time : 10/12/2023 3:53 PM
# @Author : WAN Yuwei
# @FileName: utils.py
# @Email: [email protected]
# @Github: https://github.com/yuweiwan
# @Personal Website: https://yuweiwan.github.io/
import json
import io


def _make_r_io_base(f, mode: str):
if not isinstance(f, io.IOBase):
f = open(f, mode=mode)
return f


def jload(f, mode="r"):
"""Load a .json file into a dictionary."""
f = _make_r_io_base(f, mode)
jdict = json.load(f)
f.close()
return jdict

0 comments on commit 7c3f75b

Please sign in to comment.