Skip to content

Latest commit

 

History

History
52 lines (37 loc) · 1.05 KB

readme.md

File metadata and controls

52 lines (37 loc) · 1.05 KB

python trick packages

trick codes

​ Use JSON files as if they are python modules

​ 导入json 文件作为一个包使用

  • tester.json

    {
        "hello": "world",
        "this": {
            "can": {
                "be": "nested"
            }
        }
    }
    

    Now import jsonsempai and your json file!

    >>> from jsonsempai import magic
    >>> import tester
    >>> tester
    <module 'tester' from 'tester.json'>
    >>> tester.hello
    u'world'
    >>> tester.this.can.be
    u'nested'
    >>>