精华内容
下载资源
问答
  • 2020-12-01 00:43:04

    软件简介

    PyH

    是一个用来生成HTML页面的Python模块,使用面向对象的方式,HTML的标签都会对应一个Python的对象,输出的HTML文档排版良好,易于阅读。

    示例代码:

    from pyh import *

    page = PyH(‘My wonderful PyH page’)

    page.addCSS(‘myStylesheet1.css’, ‘myStylesheet2.css’)

    page.addJS(‘myJavascript1.js’, ‘myJavascript2.js’)

    page << h1(cl=’center’, ‘My big title’)

    page << div(cl=’myCSSclass1 myCSSclass2’, id=’myDiv1’) << p(id=’myP1’, ‘I love

    PyH!’)

    mydiv2 = page << div(id=’myDiv2’)

    mydiv2 << h2(‘A smaller title’) + p(‘Followed by a paragraph.’)

    page << div(id=’myDiv3’)

    page.myDiv3.attributes[‘cl’] = ‘myCSSclass3’

    page.myDiv3 << p(‘Another paragraph’)

    page.printOut()

    更多相关内容
  • python -Pyh模块下载

    2017-10-26 10:06:44
    想用Python生成HTML格式,自动化测试、性能测试报告,必须神器,
  • Python3 pyh模块

    2017-03-06 20:49:44
    python3以上版本使用的pyh模块,用于生成html文档
  • Pyh 是一个强大且简约的python模块,你可以使用它在python程序中生成HTML内容。在python代码中手写HTML代码非常乏味并且使代码可读性变得...PyH为这一切提供了非常不错的解决方案。它让你像编写GUI一样,编写你的网页!
  • 主要介绍了Python使用pyh生成HTML文档的方法示例,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
  • PyH-0.0.2.tar.gz

    2019-06-06 10:23:40
    Pyh 是一个强大且简约的python模块,你可以使用它在python程序中生成HTML内容。在python代码中手写HTML代码非常...PyH为这一切提供了非常不错的解决方案。它让你像编写GUI一样,编写你的网页,linux系统安装可直接使用
  • #@file: pyh.py#@purpose: a HTML tag generator#@author: Emmanuel Turlay __doc__ = """The pyh.py module is the core of the PyH package. PyH lets yougenerate ...

    #@file: pyh.py#@purpose: a HTML tag generator#@author: Emmanuel Turlay

    __doc__ = """The pyh.py module is the core of the PyH package. PyH lets you

    generate HTML tags from within your python code.

    See http://code.google.com/p/pyh/ for documentation."""

    __author__ = "Emmanuel Turlay "

    __version__ = '$Revision: 43 $'

    __date__ = '$Date$'

    from sys import_getframe, stdout, modules, version

    nOpen={}

    nl= '\n'doctype= '\n'charset= '\n'tags= ['html', 'body', 'head', 'link', 'meta', 'div', 'p', 'form', 'legend','input', 'select', 'span', 'b', 'i', 'option', 'img', 'script','table', 'tr', 'td', 'th', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6','fieldset', 'a', 'title', 'body', 'head', 'title', 'script', 'br', 'table']

    selfClose= ['input', 'img', 'link', 'br']classTag(list):

    tagname= ''

    def __init__(self, *arg, **kw):

    self.attributes=kwifself.tagname :

    name=self.tagname

    self.isSeq=Falseelse:

    name= 'sequence'self.isSeq=True

    self.id= kw.get('id', name)#self.extend(arg)

    for a inarg: self.addObj(a)def __iadd__(self, obj):if isinstance(obj, Tag) andobj.isSeq:for o inobj: self.addObj(o)else: self.addObj(obj)returnselfdefaddObj(self, obj):if not isinstance(obj, Tag): obj =str(obj)

    id=self.setID(obj)

    setattr(self, id, obj)

    self.append(obj)defsetID(self, obj):ifisinstance(obj, Tag):

    id=obj.id

    n= len([t for t in self if isinstance(t, Tag) andt.id.startswith(id)])else:

    id= 'content'n= len([t for t in self if notisinstance(t, Tag)])if n: id = '%s_%03i' %(id, n)if isinstance(obj, Tag): obj.id =idreturniddef __add__(self, obj):if self.tagname: returnTag(self, obj)

    self.addObj(obj)returnselfdef __lshift__(self, obj):

    self+=objreturnobjdefrender(self):

    result= ''

    ifself.tagname:

    result= '' % (self.tagname, self.renderAtt(), self.selfClose()*'/')if notself.selfClose():for c inself:ifisinstance(c, Tag):

    result+=c.render()else: result +=cifself.tagname:

    result+= '%s>' %self.tagname

    result+= '\n'

    returnresultdefrenderAtt(self):

    result= ''

    for n, v inself.attributes.items():if n != 'txt' and n != 'open':if n == 'cl': n = 'class'result+= '%s="%s"' %(n, v)returnresultdefselfClose(self):return self.tagname inselfClosedefTagFactory(name):classf(Tag):

    tagname=name

    f.__name__ =namereturnf

    thisModule= modules[__name__]for t intags: setattr(thisModule, t, TagFactory(t))defValidW3C():

    out= a(img(src='http://www.w3.org/Icons/valid-xhtml10', alt='Valid XHTML 1.0 Strict'), href='http://validator.w3.org/check?uri=referer')returnoutclassPyH(Tag):

    tagname= 'html'

    def __init__(self, name='MyPyHPage'):

    self+=head()

    self+=body()

    self.attributes= dict(xmlns='http://www.w3.org/1999/xhtml', lang='en')

    self.head+=title(name)def __iadd__(self, obj):if isinstance(obj, head) orisinstance(obj, body): self.addObj(obj)elif isinstance(obj, meta) or isinstance(obj, link): self.head +=objelse:

    self.body+=obj

    id=self.setID(obj)

    setattr(self, id, obj)returnselfdef addJS(self, *arg):for f in arg: self.head += script(type='text/javascript', src=f)def addCSS(self, *arg):for f in arg: self.head += link(rel='stylesheet', type='text/css', href=f)def printOut(self,file=''):if file: f = open(file, 'w')else: f =stdout

    f.write(doctype)

    f.write(self.render())

    f.flush()iffile: f.close()classTagCounter:

    _count={}

    _lastOpen=[]for t in tags: _count[t] =0def __init__(self, name):

    self._name=namedefopen(self, tag):ifisLegal(tag):

    self._count[tag]+= 1self._lastOpen+=[tag]defclose(self, tag):if isLegal(tag) and self._lastOpen[-1] ==tag:

    self._count[tag]-= 1self._lastOpen.pop()else:print('Cross tagging is wrong')defisAllowed(self, tag, open):if not open andself.isClosed(tag):print('TRYING TO CLOSE NON-OPEN TAG: %s' %tag)returnFalsereturnTruedefisOpen(self, tag):if isLegal(tag): returnself._count[tag]defisClosed(self, tag):if isLegal(tag): return notself._count[tag]defisLegal(tag):if tag in tags: returnTrueelse:print('ILLEGAL TAG: %s' %tag)return False

    展开全文
  • pyH支持python3

    2020-12-01 01:17:02
    1 #@file: pyh.py2 #@purpose: a HTML tag generator3 #@author: Emmanuel Turlay 45 __doc__ = """The pyh.py module is the core of the PyH package. PyH lets you6 generate ...

    1 #@file: pyh.py

    2 #@purpose: a HTML tag generator

    3 #@author: Emmanuel Turlay

    4

    5 __doc__ = """The pyh.py module is the core of the PyH package. PyH lets you6 generate HTML tags from within your python code.7 See http://code.google.com/p/pyh/ for documentation.8 """

    9 __author__ = "Emmanuel Turlay "

    10 __version__ = '$Revision: 43 $'

    11 __date__ = '$Date$'

    12

    13 from sys import_getframe, stdout, modules, version14 nOpen={}15

    16 nl = '\n'

    17 doctype = '\n'

    18 charset = '\n'

    19

    20 tags = ['html', 'body', 'head', 'link', 'meta', 'div', 'p', 'form', 'legend',21 'input', 'select', 'span', 'b', 'i', 'option', 'img', 'script',22 'table', 'tr', 'td', 'th', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6',23 'fieldset', 'a', 'title', 'body', 'head', 'title', 'script', 'br', 'table']24

    25 selfClose = ['input', 'img', 'link', 'br']26

    27 classTag(list):28 tagname = ''

    29

    30 def __init__(self, *arg, **kw):31 self.attributes =kw32 ifself.tagname :33 name =self.tagname34 self.isSeq =False35 else:36 name = 'sequence'

    37 self.isSeq =True38 self.id = kw.get('id', name)39 #self.extend(arg)

    40 for a inarg: self.addObj(a)41

    42 def __iadd__(self, obj):43 if isinstance(obj, Tag) andobj.isSeq:44 for o inobj: self.addObj(o)45 else: self.addObj(obj)46 returnself47

    48 defaddObj(self, obj):49 if not isinstance(obj, Tag): obj =str(obj)50 id=self.setID(obj)51 setattr(self, id, obj)52 self.append(obj)53

    54 defsetID(self, obj):55 ifisinstance(obj, Tag):56 id =obj.id57 n = len([t for t in self if isinstance(t, Tag) andt.id.startswith(id)])58 else:59 id = 'content'

    60 n = len([t for t in self if notisinstance(t, Tag)])61 if n: id = '%s_%03i' %(id, n)62 if isinstance(obj, Tag): obj.id =id63 returnid64

    65 def __add__(self, obj):66 if self.tagname: returnTag(self, obj)67 self.addObj(obj)68 returnself69

    70 def __lshift__(self, obj):71 self +=obj72 returnobj73

    74 defrender(self):75 result = ''

    76 ifself.tagname:77 result = '' % (self.tagname, self.renderAtt(), self.selfClose()*'/')78 if notself.selfClose():79 for c inself:80 ifisinstance(c, Tag):81 result +=c.render()82 else: result +=c83 ifself.tagname:84 result += '%s>' %self.tagname85 result += '\n'

    86 returnresult87

    88 defrenderAtt(self):89 result = ''

    90 for n, v inself.attributes.items():91 if n != 'txt' and n != 'open':92 if n == 'cl': n = 'class'

    93 result += '%s="%s"' %(n, v)94 returnresult95

    96 defselfClose(self):97 return self.tagname inselfClose98

    99 defTagFactory(name):100 classf(Tag):101 tagname =name102 f.__name__ =name103 returnf104

    105 thisModule = modules[__name__]106

    107 for t intags: setattr(thisModule, t, TagFactory(t))108

    109 defValidW3C():110 out = a(img(src='http://www.w3.org/Icons/valid-xhtml10', alt='Valid XHTML 1.0 Strict'), href='http://validator.w3.org/check?uri=referer')111 returnout112

    113 classPyH(Tag):114 tagname = 'html'

    115

    116 def __init__(self, name='MyPyHPage'):117 self +=head()118 self +=body()119 self.attributes = dict(xmlns='http://www.w3.org/1999/xhtml', lang='en')120 self.head +=title(name)121

    122 def __iadd__(self, obj):123 if isinstance(obj, head) orisinstance(obj, body): self.addObj(obj)124 elif isinstance(obj, meta) or isinstance(obj, link): self.head +=obj125 else:126 self.body +=obj127 id=self.setID(obj)128 setattr(self, id, obj)129 returnself130

    131 def addJS(self, *arg):132 for f in arg: self.head += script(type='text/javascript', src=f)133

    134 def addCSS(self, *arg):135 for f in arg: self.head += link(rel='stylesheet', type='text/css', href=f)136

    137 def printOut(self,file=''):138 if file: f = open(file, 'w')139 else: f =stdout140 f.write(doctype)141 f.write(self.render())142 f.flush()143 iffile: f.close()144

    145 classTagCounter:146 _count ={}147 _lastOpen =[]148 for t in tags: _count[t] =0149 def __init__(self, name):150 self._name =name151 defopen(self, tag):152 ifisLegal(tag):153 self._count[tag] += 1

    154 self._lastOpen +=[tag]155 defclose(self, tag):156 if isLegal(tag) and self._lastOpen[-1] ==tag:157 self._count[tag] -= 1

    158 self._lastOpen.pop()159 else:160 print('Cross tagging is wrong')161 defisAllowed(self, tag, open):162 if not open andself.isClosed(tag):163 print('TRYING TO CLOSE NON-OPEN TAG: %s' %tag)164 returnFalse165 returnTrue166 defisOpen(self, tag):167 if isLegal(tag): returnself._count[tag]168 defisClosed(self, tag):169 if isLegal(tag): return notself._count[tag]170

    171

    172 defisLegal(tag):173 if tag in tags: returnTrue174 else:175 print('ILLEGAL TAG: %s' %tag)176 return False

    展开全文
  • python3 pyh模块的安装

    千次阅读 2020-09-14 21:23:04
    需要下载pyh 的源码(文末附上pyh模块的源码),然后在安装python3 的项目路径在安装,比如说 你的python3 的项目路径是 D:/PycharmProjects/Alex 这个目录下,那么你就把pyh.py这个源码文件放在这个目录下,然后打...

    为了用python生成html样式的文件。需要安装pyh模块。

    python3 对应的pycharm 里边不能直接安装pyh模块 。需要下载pyh 的源码(文末附上pyh模块的源码),然后在安装python3 的项目路径在安装,比如说 你的python3 的项目路径是 D:/PycharmProjects/Alex 这个目录下,那么你就把pyh.py这个源码文件放在这个目录下,然后打来cmd ,cd 到这个路径下 即D:/PycharmProjects/Alex ,然后输入一条命令 python pyh.py 回车;
    验证是否安装成功:继续在终端输入python 然后回车 。然后再输入 import pyh 能够运行就说明成功了;

    from sys import _getframe, stdout, modules, version
    nOpen={}

    nl = ‘\n’
    doctype = ‘\n’
    charset = ‘\n’

    tags = [‘html’, ‘body’, ‘head’, ‘link’, ‘meta’, ‘div’, ‘p’, ‘form’, ‘legend’,
    ‘input’, ‘select’, ‘span’, ‘b’, ‘i’, ‘option’, ‘img’, ‘script’,
    ‘table’, ‘tr’, ‘td’, ‘th’, ‘h1’, ‘h2’, ‘h3’, ‘h4’, ‘h5’, ‘h6’,
    ‘fieldset’, ‘a’, ‘title’, ‘body’, ‘head’, ‘title’, ‘script’, ‘br’, ‘table’]

    selfClose = [‘input’, ‘img’, ‘link’, ‘br’]

    class Tag(list):
    tagname = ‘’

    def __init__(self, *arg, **kw):
        self.attributes = kw
        if self.tagname : 
            name = self.tagname
            self.isSeq = False
        else: 
            name = 'sequence'
            self.isSeq = True
        self.id = kw.get('id', name)
        #self.extend(arg)
        for a in arg: self.addObj(a)
    
    def __iadd__(self, obj):
        if isinstance(obj, Tag) and obj.isSeq:
            for o in obj: self.addObj(o)
        else: self.addObj(obj)
        return self
    
    def addObj(self, obj):
        if not isinstance(obj, Tag): obj = str(obj)
        id=self.setID(obj)
        setattr(self, id, obj)
        self.append(obj)
    
    def setID(self, obj):
        if isinstance(obj, Tag):
            id = obj.id
            n = len([t for t in self if isinstance(t, Tag) and t.id.startswith(id)])
        else:
            id = 'content'
            n = len([t for t in self if not isinstance(t, Tag)])
        if n: id = '%s_%03i' % (id, n)
        if isinstance(obj, Tag): obj.id = id
        return id
    
    def __add__(self, obj):
        if self.tagname: return Tag(self, obj)
        self.addObj(obj)
        return self
    
    def __lshift__(self, obj):
        self += obj
        return obj
    
    def render(self):
        result = ''
        if self.tagname:
            result = '<%s%s%s>' % (self.tagname, self.renderAtt(), self.selfClose()*' /')
        if not self.selfClose():
            for c in self:
                if isinstance(c, Tag):
                    result += c.render()
                else: result += c
            if self.tagname: 
                result += '</%s>' % self.tagname
        result += '\n'
        return result
    
    def renderAtt(self):
        result = ''
        for n, v in self.attributes.items():
            if n != 'txt' and n != 'open':
                if n == 'cl': n = 'class'
                result += ' %s="%s"' % (n, v)
        return result
    
    def selfClose(self):
        return self.tagname in selfClose        
    

    def TagFactory(name):
    class f(Tag):
    tagname = name
    f.name = name
    return f

    thisModule = modules[name]

    for t in tags: setattr(thisModule, t, TagFactory(t))

    def ValidW3C():
    out = a(img(src=‘http://www.w3.org/Icons/valid-xhtml10’, alt=‘Valid XHTML 1.0 Strict’), href=‘http://validator.w3.org/check?uri=referer’)
    return out

    class PyH(Tag):
    tagname = ‘html’

    def __init__(self, name='MyPyHPage'):
        self += head()
        self += body()
        self.attributes = dict(xmlns='http://www.w3.org/1999/xhtml', lang='en')
        self.head += title(name)
    
    def __iadd__(self, obj):
        if isinstance(obj, head) or isinstance(obj, body): self.addObj(obj)
        elif isinstance(obj, meta) or isinstance(obj, link): self.head += obj
        else:
            self.body += obj
            id=self.setID(obj)
            setattr(self, id, obj)
        return self
    
    def addJS(self, *arg):
        for f in arg: self.head += script(type='text/javascript', src=f)
    
    def addCSS(self, *arg):
        for f in arg: self.head += link(rel='stylesheet', type='text/css', href=f)
    
    def printOut(self,file=''):
        if file: f = open(file, 'w')
        else: f = stdout
        f.write(doctype)
        f.write(self.render())
        f.flush()
        if file: f.close()
    

    class TagCounter:
    _count = {}
    _lastOpen = []
    for t in tags: _count[t] = 0
    def init(self, name):
    self._name = name
    def open(self, tag):
    if isLegal(tag):
    self._count[tag] += 1
    self._lastOpen += [tag]
    def close(self, tag):
    if isLegal(tag) and self._lastOpen[-1] == tag:
    self._count[tag] -= 1
    self._lastOpen.pop()
    else:
    print(‘Cross tagging is wrong’)
    def isAllowed(self, tag, open):
    if not open and self.isClosed(tag):
    print(‘TRYING TO CLOSE NON-OPEN TAG: %s’ % tag)
    return False
    return True
    def isOpen(self, tag):
    if isLegal(tag): return self._count[tag]
    def isClosed(self, tag):
    if isLegal(tag): return not self._count[tag]

    def isLegal(tag):
    if tag in tags: return True
    else:
    print(‘ILLEGAL TAG: %s’ % tag)
    return False

    参考自:https://blog.csdn.net/weixin_30706691/article/details/97035704

    : https://blog.csdn.net/jing186/article/details/72626729

    展开全文
  • 程序的假异构现象:(pyH) 的半水合物和一水合物的晶体结构 [MnF (H2PO4) (HPO4)] 不同的 Jahn-Teller 程序的假异构现象:半水合物和单水合物的晶体结构(pyH) [MnF (H2PO4) (HPO4)] Ronald Stief 和 Werner Massa * ...
  • 1 #!/usr/bin/env python2 #-*- coding:utf-8 -*-34 from pyh import *56 page = PyH('接口测试报告') #第一步:需要先生成含标题的HTML模板7 page.addCSS('...
  • python-PyH

    热门讨论 2012-11-13 19:28:05
    PyH 0.1 Python用来生成HTML的一个工具 安装: $ python setup.py build $ sudo python setup.py install
  • Python PyH模块中文文档

    千次阅读 2017-05-22 15:19:55
     模块介绍 Pyh 是一个强大且简约的python模块,你可以使用它在python...PyH为这一切提供了非常不错的解决方案。它让你像编写GUI一样,编写你的网页! 功能特性 自动格式化HTML标签高度可定制完全识别CSS和Jav
  • 非负矩阵划分matlab代码pyh2nmf 基于 Gillis 等人的 matlab 实现的分层 rank-2 非负矩阵分解的 python 端口。 2014年 原始matlab代码在这里: 论文:参见 N. Gillis、D. Kuang 和 H. Park,“使用 Rank-Two Non...
  • PyH : python生成html

    2021-03-06 22:18:20
    样例下面是官网的一个例子:from pyh import *page = PyH('My wonderful PyH page')page.addCSS('myStylesheet1.css', 'myStylesheet2.css')page.addJS('myJavascript1.js', 'myJavascript2.js')page <...
  • pyh为了这一切提供了非常不错的解决方案。它让你像编写GUI一样,编写网页1.2 日常使用HTML确定在python代码中手写HTML代码非常乏味并且使代码可读性变得非常槽糕。当你尝试要去看一下HTML源码的时候,可读性同样很差...
  • (PyH) 4 [Al2F10] [hairsp] · [hairsp] 4 [hairsp] H2O 合成、晶体结构和氟铝酸盐的热降解与组成 (NH4) [M (H2O) 6] [AlF6] (M = Zn, Ni) , [Zn (H2O) 6] [AlF5 (H2O)] 和 (PyH) 4 [Al2F10] ´ 4 H2O B. Adamczyka...
  • 在配合物型分子导体(PyH)[Pd(amit)2]2和(PyH)[Ni(dmit)2]2中,阴离子导电组元[M(dmit)2]0.5-(M=Pd,Ni)的面对面堆积和肩并肩排列形成二维层状结构。采用推广休克尔紧束缚方法计算了二维导电层中相邻两阴...
  • Pseudo-Isomerie durch unterschiedliche Jahn-Teller-Ordnung: Die Kristallstrukturen des Hemihydrats und des Monohydrats von (pyH)[MnF(H2PO4)(HPO4)] Pseudo-Isomerie durch unterschiedliche Jahn-Teller-...
  • Synthese, Kristallstruktur und thermischer Abbau von Fluoroaluminaten der Zusammensetzung (NH4)[M(H2O)6][AlF6] (M[hairsp]=[hairsp]Zn, Ni), [Zn(H2O)6][AlF5(H2O)] und (PyH)4[Al2F10][hairsp]·[hairsp]4...
  • pyh 模块生成html

    2019-04-09 01:01:46
    NULL 博文链接:https://jebai0521.iteye.com/blog/1616652
  • pyh2o - Python绑定H2O HTTP服务器
  • 报错界面: Preparing transaction: ...ERROR conda.core.link:_execute(502): An error occurred while installing package 'conda-forge::olefile-0.46-pyh9f0ad1d_1'. FileNotFoundError(2, "No such file or dire

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 1,867
精华内容 746
关键字:

pyh

友情链接: 闸显示牌-v2.3.zip