HTML类
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='<html>\n%s%s\n</html>' % (self.head(),self.body(content))
print(res)
return res def structure(self):
'''html结构'''
self.type()
self.html_first() def head(self):
res = '<head>\n<title>%s</title>\n</head>\n' % self.name
return res @staticmethod
def body(content):
res = '<body>\n%s\n</body>' % 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 '<br>' @staticmethod
def hr():
'''文章和文章之间进行添加横线'''
return '<hr>' @staticmethod
def meta(mode='UTF-8'):
'''字符编码是gbk还是utf8'''
return '<meta charset=%s>' % mode @staticmethod
def img():
'''图片标签'''
return '<img >' @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<input type='%s' placeholder='%s' name='%s' check='%s' value='%s'>" \
% (content,type,placeholder,name,check,value)
单闭合标签
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>\n' % i
res += single
return res @staticmethod
def ul(li=None):
'''无序列表(unorder line)'''
return '<ul>\n%s\n</li>' % li @staticmethod
def ol(li=None):
'''有序列表(order line)'''
return '<ol>\n%s\n</ol>' % li @staticmethod
def dl(title=None,describe=None):
'''
定义列表
:param title:元组
:param describe: 元组
:return:
'''
res1 = ''
for i in title:
single1 = '<dt>%s</dt>\n' % i
res1 += single1
res2 = ''
for i in describe:
single2 = '<dd>%s</dd>\n' % i
res2 += single2
res= '<dl>\n%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>\n' % caption
res1 = ''
for i in head:
all_head = ''
single1 = '<th>%s</th>\n' % i
all_head += single1
res1 += all_head
res1 = '<tr>\n' + res1 + '</tr>\n'
res2 = ''
for t in describe:
all_head = ''
for i in t:
single2 = '<td>%s</td>\n' % i
all_head += single2
res3 = '<tr>\n' + all_head + '</tr>\n'
res2 += res3 res = "<table border='%d'>\n%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>\n%s\n</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">\n%s\n</from>' % (action,method,content)
多闭合标签
HTML类的更多相关文章
- Java类的继承与多态特性-入门笔记
相信对于继承和多态的概念性我就不在怎么解释啦!不管你是.Net还是Java面向对象编程都是比不缺少一堂课~~Net如此Java亦也有同样的思想成分包含其中. 继承,多态,封装是Java面向对象的3大特 ...
- C++ 可配置的类工厂
项目中常用到工厂模式,工厂模式可以把创建对象的具体细节封装到Create函数中,减少重复代码,增强可读和可维护性.传统的工厂实现如下: class Widget { public: virtual i ...
- Android请求网络共通类——Hi_博客 Android App 开发笔记
今天 ,来分享一下 ,一个博客App的开发过程,以前也没开发过这种类型App 的经验,求大神们轻点喷. 首先我们要创建一个Andriod 项目 因为要从网络请求数据所以我们先来一个请求网络的共通类. ...
- ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第二章:利用模型类创建视图、控制器和数据库
在这一章中,我们将直接进入项目,并且为产品和分类添加一些基本的模型类.我们将在Entity Framework的代码优先模式下,利用这些模型类创建一个数据库.我们还将学习如何在代码中创建数据库上下文类 ...
- ASP.NET Core 折腾笔记二:自己写个完整的Cache缓存类来支持.NET Core
背景: 1:.NET Core 已经没System.Web,也木有了HttpRuntime.Cache,因此,该空间下Cache也木有了. 2:.NET Core 有新的Memory Cache提供, ...
- .NET Core中间件的注册和管道的构建(2)---- 用UseMiddleware扩展方法注册中间件类
.NET Core中间件的注册和管道的构建(2)---- 用UseMiddleware扩展方法注册中间件类 0x00 为什么要引入扩展方法 有的中间件功能比较简单,有的则比较复杂,并且依赖其它组件.除 ...
- Java基础Map接口+Collections工具类
1.Map中我们主要讲两个接口 HashMap 与 LinkedHashMap (1)其中LinkedHashMap是有序的 怎么存怎么取出来 我们讲一下Map的增删改查功能: /* * Ma ...
- PHP-解析验证码类--学习笔记
1.开始 在 网上看到使用PHP写的ValidateCode生成验证码码类,感觉不错,特拿来分析学习一下. 2.类图 3.验证码类部分代码 3.1 定义变量 //随机因子 private $char ...
- C# 多种方式发送邮件(附帮助类)
因项目业务需要,需要做一个发送邮件功能,查了下资料,整了整,汇总如下,亲测可用- QQ邮箱发送邮件 #region 发送邮箱 try { MailMessage mail = new MailMess ...
- .NET平台开源项目速览(18)C#平台JSON实体类生成器JSON C# Class Generator
去年,我在一篇文章用原始方法解析复杂字符串,json一定要用JsonMapper么?中介绍了简单的JSON解析的问题,那种方法在当时的环境是非常方便的,因为不需要生成实体类,结构很容易解析.但随着业务 ...
随机推荐
- [drf]源码和序列化梳理
drf源码继承管理 # drf继承关系 View APIView as_view: 执行父类的as_view 调用dispatch dispatch init_request request.quer ...
- Qt编写安防视频监控系统10-视频轮询
一.前言 视频轮询在视频监控系统中是一个基础的核心功能,尤其是上了大屏以后,这个功能是必须的,根据预先设定的轮询间隔逐个加载视频到预先设定的通道画面数中,轮询间隔.轮询画面数.轮询采用的码流类型(主码 ...
- windows10 企业版 安装应用商店
安装windows10企业版后,提示 没有nvdia control panel 在其他位置下载均不成功 必须在win10自带的应用商店中安装,但win10企业版没有应用商店, 使用下方的网盘安装应用 ...
- 当微信小程序遇到AR(三)
当微信小程序遇到AR,会擦出怎么样的火花?期待与激动...... 通过该教程,可以从基础开始打造一个微信小程序的AR框架,所有代码开源,提供大家学习. 本课程需要一定的基础:微信开发者工具,JavaS ...
- 78 leetCode 位运算解法
按照自己的理解题目,数组内所有的组合:假如[1,2,3,4]看成1111到0000里面的排列组合,取位运算. vector<vector > subsets(vector&nums ...
- 【ARM-Linux开发】"libxml/parser.h: 没有那个文件或目录"解决方案
这是因为在ubuntu上没有安装libxml2-dev,这个包应该是开发用的,而已安装的libxml2应该只是像jre一样的部件. 解决方案:sudo apt-get install libxml2- ...
- A+B Problem Plus and A-B Problem Plus and A*B Problem Plus
//we have defined the necessary header files here for this problem. //If additional header files are ...
- 更改oracle RAC public ip,vip,scan ip和private ip
更改oracle RAC public ip,vip,scan ip和private ip oifcfg - Oracle 接口配置工具 用法: oifcfg iflist [-p [-n]] ...
- Redis 数据结构 & 原理 & 持久化
一 概述 redis是一种高级的key-value数据库,它跟memcached类似,不过数据可以持久化,而且支持的数据类型也很丰富. Redis支持五种数据类型:string(字符串),hash(哈 ...
- 剑指offer47:位运算+递归。求1+2+3+...+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。
1 题目描述 求1+2+3+...+n,要求不能使用乘除法.for.while.if.else.switch.case等关键字及条件判断语句(A?B:C). 2 思路和方法 (1)递归,不能使用if等 ...