brysj22952 avatar

PyH源码解析(2)

brysj22952

Published: 09 Aug 2018 › Updated: 09 Aug 2018

PyH源码解析(2)

生成Tag对象的属性

用户代码如下所示:

>>> a=div(a1='a1')
>>> print(a)
<div a1="a1">
</div>

在内部实现上,Tag对象的属性存放在一个字典中,字典的名字是attr,原来的名字是attributes,我觉得太长了,修改了一下。核心函数如下:

#把字典变成字符串,形如:' a="a" b="b"'
#需要注意的是class需要换成cl
renderAttr(self)->str

Leave PyH源码解析(2) to:

Written by

Read more #cn posts


Best Posts From brysj22952

We have not curated any of brysj22952's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From brysj22952