class Label1:
'''多闭合标签'''
@staticmethod
def p(content=None):
'''段落标签'''
return '<p>%s</p>' % content
@staticmethod
def strong(content=None):
'''文本内容加粗,重强调'''
return '<strong>%s</strong>' % content
@staticmethod
def em(content=None):
'''文本内容斜体,轻强调'''
return '<em>%s</em>' % content
@staticmethod
def li(args=None):
'''
粒标签
:param args:元组
:return:
'''
res = ''
for i in args:
single = '<li>%s</li>
' % i
res += single
return res
@staticmethod
def ul(li=None):
'''无序列表(unorder line)'''
return '<ul>
%s
</li>' % li
@staticmethod
def ol(li=None):
'''有序列表(order line)'''
return '<ol>
%s
</ol>' % li
@staticmethod
def dl(title=None,describe=None):
'''
定义列表
:param title:元组
:param describe: 元组
:return:
'''
res1 = ''
for i in title:
single1 = '<dt>%s</dt>
' % i
res1 += single1
res2 = ''
for i in describe:
single2 = '<dd>%s</dd>
' % i
res2 += single2
res= '<dl>
%s%s</dl>' % (res1,res2)
return res
@staticmethod
def table(head=None,describe=None,caption=None,border=0):
'''
:param head:
:param describe:元组,一个元素代表一行,一个元素有多少项代表有多少列,如((xx,xx),(xx,xx))
:param border: 宽度
:return:
'''
res0 = '<caption>%s</caption>
' % caption
res1 = ''
for i in head:
all_head = ''
single1 = '<th>%s</th>
' % i
all_head += single1
res1 += all_head
res1 = '<tr>
' + res1 + '</tr>
'
res2 = ''
for t in describe:
all_head = ''
for i in t:
single2 = '<td>%s</td>
' % i
all_head += single2
res3 = '<tr>
' + all_head + '</tr>
'
res2 += res3
res = "<table border='%d'>
%s%s%s</table>" % (border,caption,res1, res2)
return res
@staticmethod
def a(web=None,name=None,target='self'):
'''段落标签'''
return "<a href='%s' target='%s'>%s</a>" % (web,target,name)
@staticmethod
def textarea(rows=None,cols=None):
'''文本域标签'''
if rows and cols:
return '<textarea rows="%s" cols="%s"></textarea>' % (rows,cols)
else:
return '<textarea></textarea>'
@staticmethod
def laber(id=None,text=None):
'''标记标签,鼠标点击文本后跳转到关联的from内容'''
return '<laber for="%s">%s</laber>' % (id,text)
@staticmethod
def div(content=None):
'''区隔标签'''
return '<div>
%s
</div>' % content
@staticmethod
def select(content=None,multiple='multiple'):
'''选择标签'''
return '<select multiple="%s">%s</select>' % (multiple,content)
@staticmethod
def option(content=None,value='',selected=''):
'''选项标签,会根据内容数目自动出现滚筒'''
if value:
return '<option value="%s" selected="%s">%s</option>' % (value,content,selected)
else:
return '<option value="%s" selected="%s">%s</option>' % (content,content,selected)
@staticmethod
def from_html(content=None,action='#',method='get'):
'''
from表单标签
:param content:
:param action: 服务器地址
:param method:
:return:
'''
return '<from action="%s" method="%s">
%s
</from>' % (action,method,content)