小编Gui*_*rmo的帖子

AttributeError:类型对象'ElementTree'没有属性'tostring'

我有这个问题,AttributeError: type object 'ElementTree' has no attribute 'tostring'我不知道什么是错的,我导入到字符串,它不起作用.尝试按照另一个教程,但没有.

有没有其他方法将ElementTree对象转换为XML字符串?

import os
import re
import glob
from xml.dom import minidom
from time import strftime
from xml.etree.ElementTree import ElementTree
from xml.etree.ElementTree import Element, SubElement, Comment, tostring
date=strftime("%Y-%m-%dT%H:%M:%S")
os.chdir('/home/guillermo/TclsPy/XML_Level2/')

def prettify(elem):
    """Return a pretty-printed XML string for the Element.
    """
    rough_string = ElementTree.tostring(elem, 'utf-8',method="xml" ,     short_empty_elements=True)
    reparsed = minidom.parseString(rough_string)
    return reparsed.toprettyxml(indent=" ")





for nameXml in glob.glob("*.xml"):
    new_nameXml = re.sub(r'tlmy',r'AUX',nameXml,flags=re.IGNORECASE)
    new_nameXml = re.sub('.xml','_AlarmEnabled.xml',new_nameXml, flags=re.IGNORECASE)#new_nameXml.lower().replace('.xml','_AlarmEnabled.xml')
    match = re.search(r'TSL_TM_TLMY_(.+).xml', nameXml,flags= re.IGNORECASE )
    if match: …
Run Code Online (Sandbox Code Playgroud)

xml tostring elementtree python-2.7

9
推荐指数
2
解决办法
2万
查看次数

如何从几个INSERT中插入id

我有这个查询:

$consulta = $this->db->consulta("INSERT INTO prestamo_equipo (id_equipo, id_usuario, fecha_devolucion) VALUES $valor ");
Run Code Online (Sandbox Code Playgroud)

哪里$valor('1', '75', 'xs', '2015-12-14'),('1', '75', 'xs', '2015-12-14').

$id = $this->db->getInsertId($consulta);
Run Code Online (Sandbox Code Playgroud)

这最后一行,只返回第一个插入ID,而不是另一个,我想要两个插入的id.

php mysql insert

4
推荐指数
1
解决办法
47
查看次数

标签 统计

elementtree ×1

insert ×1

mysql ×1

php ×1

python-2.7 ×1

tostring ×1

xml ×1