class Html: def __init__(self,name): self.name = name @staticmethod def full_name(): print('全称:Hype Text Makeup Language') print('中文名称:超文本标记语言') @staticmethod def history(): print('历史:') dic = {} dic.setdefault('1.0版本',1993.06) dic.setdefault('2.0版本',1995.11) dic.setdefault('3.2版本',1997.01) dic.setdefault('4.01版本',1999.12) dic.setdefault('4.01版本',2000.05) dic.setdefault('5.0版本',2014.10) for k, v in dic.items(): print('版本:', k, '\t时间: ',v) @staticmethod def type(): print('< !DOCTYPE html >') # 声明是哪个版本的 def html_first(self,content=None): res='\n%s%s\n' % (self.head(),self.body(content)) print(res) return res def structure(self): '''html结构''' self.type() self.html_first() def head(self): res = '\n%s \n\n' % self.name return res @staticmethod def body(content): res = '\n%s\n' % content return res @staticmethod def black(n=1): '''空白符号''' res = ' ' * n return res @staticmethod def show_label(): print(""" 1:h1-h6,标题 2:p,段落 3:strong/em,强调 4:hr,文章与文章间的分割 5:br,换行 6:ul/ol,列表 7:div/span,排版布局 8:li,粒 9:table,表格 10:a,超链接 11:img,图片 12:from,列表,服务器交互 13:input,输入 14:textarea,多行输入 15:select,下拉列表\n """)
class Label: '''单闭合标签''' @staticmethod def br(): '''换行,注意空白折叠现象''' return '
' @staticmethod def hr(): '''文章和文章之间进行添加横线''' return '
' @staticmethod def meta(mode='UTF-8'): '''字符编码是gbk还是utf8''' return '' % mode @staticmethod def img(): '''图片标签''' return '' @staticmethod def input(type,content,check='check',name='',placeholder='',value=''): ''' 和from表单结合使用 :param type:明文:text,密文:password,圆点:radio,复选框:checkbox,重置:reset(针对from) :param content: 显示内容 :param check: 默认选中(有选择框) :param name: 互斥 :param placeholder:提示 :param value:按钮上显示的内容,发送给服务端 :return: ''' return "%s" \ % (content,type,placeholder,name,check,value)
class Label1: '''多闭合标签''' @staticmethod def p(content=None): '''段落标签''' return '%s
' % content @staticmethod def strong(content=None): '''文本内容加粗,重强调''' return '%s' % content @staticmethod def em(content=None): '''文本内容斜体,轻强调''' return '%s' % content @staticmethod def li(args=None): ''' 粒标签 :param args:元组 :return: ''' res = '' for i in args: single = '%s \n' % i res += single return res @staticmethod def ul(li=None): '''无序列表(unorder line)''' return '\n%s\n
' % li @staticmethod def ol(li=None): '''有序列表(order line)''' return '\n%s\n
' % li @staticmethod def dl(title=None,describe=None): ''' 定义列表 :param title:元组 :param describe: 元组 :return: ''' res1 = '' for i in title: single1 = '%s \n' % i res1 += single1 res2 = '' for i in describe: single2 = '%s \n' % i res2 += single2 res= '\n%s%s
' % (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 = '%s \n' % caption res1 = '' for i in head: all_head = '' single1 = '%s \n' % i all_head += single1 res1 += all_head res1 = '\n' + res1 + ' \n' res2 = '' for t in describe: all_head = '' for i in t: single2 = '%s \n' % i all_head += single2 res3 = '\n' + all_head + ' \n' res2 += res3 res = "\n%s%s%s
" % (border,caption,res1, res2) return res @staticmethod def a(web=None,name=None,target='self'): '''段落标签''' return "%s" % (web,target,name) @staticmethod def textarea(rows=None,cols=None): '''文本域标签''' if rows and cols: return '' % (rows,cols) else: return '' @staticmethod def laber(id=None,text=None): '''标记标签,鼠标点击文本后跳转到关联的from内容''' return '%s ' % (id,text) @staticmethod def div(content=None): '''区隔标签''' return '\n%s\n' % content @staticmethod def select(content=None,multiple='multiple'): '''选择标签''' return '' % (multiple,content) @staticmethod def option(content=None,value='',selected=''): '''选项标签,会根据内容数目自动出现滚筒''' if value: return '' % (value,content,selected) else: return '' % (content,content,selected) @staticmethod def from_html(content=None,action='#',method='get'): ''' from表单标签 :param content: :param action: 服务器地址 :param method: :return: ''' return '\n%s\n ' % (action,method,content)