用于生成字符串、XML/HTML标记和其他缩进文本的工具。
indenti的Python项目详细描述
关于indenti
==indenti
==indenti是一个python包,它有生成字符串的工具,
编写缩进文本,生成标记更简单、更漂亮。
indenti包含以下模块:
-indentwriter
-xmlwriter
-stringbuilder
用Python3点,请执行以下操作:
$sudo pip install-e.
about indentwriter
===
它跟踪缩进级别,并提供一种pythonic方法,即使用可选的“with”语法递增和递减缩进级别。默认情况下,indentwriter写入sys.stdout,但可以告诉
在构造时写入任何其他文件对象。
indentwriter(使用'with'):
:
indenti import indentwriter
iw=indentwriter()
iw('def hello():')
iw('print“hello!”)
示例用法,indentwriter(不带'with'):
:
indenti import indentwriter
iw=indentwriter()
iw('def hello():')
iw.indent()
iw('print“hello!”)
示例用法,indentStringBuilder:
::
print str(sb)
关于xmlfactory
类hello world:
def index(self):
xf=xmlfactory()
xf.head(
xf.title(“你好,世界!”),
xf.body(
xf.h1(“你好,Cherrypy!”,style='color:red;FONT SIZE:20px'))
return str(xml)
在这种情况下,我们传递一个
字典,它被解释为节点的属性映射。
如果这是您的首选项,则可以始终执行此操作,而不使用关键字参数。
xmlwriter(使用与
python关键字冲突的属性/节点):
::
import cherrypy
from indenti import xmlfactory
class helloworld:
def index(self):
xf=xmlfactory()
xml=xf.html(
xf.head(
xf.title(“你好,世界!”),
xf.body(
xf.h1(“你好,Cherrypy!”{'class':'header')))
return str(xml)
>index.expose=true
>
>>
>
>更改日志
>1.4版1.4:2017年4月22日2017年4月22日
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~我是说,2016年
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
==indenti
==indenti是一个python包,它有生成字符串的工具,
编写缩进文本,生成标记更简单、更漂亮。
indenti包含以下模块:
-indentwriter
-xmlwriter
-stringbuilder
用Python3点,请执行以下操作:
$sudo pip install-e.
about indentwriter
===
在构造时写入任何其他文件对象。
indentwriter(使用'with'):
:
indenti import indentwriter
iw=indentwriter()
iw('def hello():')
iw('print“hello!”)
示例用法,indentwriter(不带'with'):
:
indenti import indentwriter
iw=indentwriter()
iw('def hello():')
iw.indent()
iw('print“hello!”)
示例用法,indentStringBuilder:
::
print str(sb)
关于xmlfactory
类hello world:
def index(self):
xf=xmlfactory()
xf.title(“你好,世界!”),
xf.body(
xf.h1(“你好,Cherrypy!”,style='color:red;FONT SIZE:20px'))
return str(xml)
在这种情况下,我们传递一个
字典,它被解释为节点的属性映射。
如果这是您的首选项,则可以始终执行此操作,而不使用关键字参数。
xmlwriter(使用与
python关键字冲突的属性/节点):
::
import cherrypy
from indenti import xmlfactory
class helloworld:
def index(self):
xf=xmlfactory()
xml=xf.html(
xf.head(
xf.title(“你好,世界!”),
xf.body(
xf.h1(“你好,Cherrypy!”{'class':'header')))
return str(xml)
>index.expose=true
>
>>
>
>更改日志
>1.4版1.4:2017年4月22日2017年4月22日
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~我是说,2016年
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~