通过python生成py对象
我想知道是否有一个渲染库可以接受字典对象并将文件渲染为 py-object 语法。与django_extensions
命令dump_script
类似。我环顾四周一个小时,但到目前为止还没有成功。我知道创建不需要很长时间,但我想看看是否有支持此功能的模块。
I was wondering if there was a rendering library that would take a dictionary object and render a file into py-object syntax. Similar to the django_extensions
command dump_script
. I've looked around for an hour but have got no success as of yet. I know it wouldn't take me long to create, but I want to see if there is a supported module for this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您想从对象生成代码吗?这对于某些内置类型是可能的,因此如果您将自己限制为它们,它就可以工作,并且可以通过
repr()
函数完成。一般来说,它不是特别有用,因此您可能需要解释一下您的用例。
You want to generate code from objects? This is possible for some built-in types so if you restrict yourself to them it works, and it's done with the
repr()
function.In general it's not particularly useful, so you might want to explain your use case.