小编SR *_*ery的帖子

如何以编程方式检查电子邮件是否存在

如何编写代码来检查电子邮件是否存在?例如,donkey_sdh123 @ gmail.com,donkey_sdh123 @ yahoo.com或donkey_sdh123@lycos.com所有这些电子邮件都不存在于gmail,yahoo和lycos数据库中.
在此输入图像描述


查看截图.donkey_sdh123@gmail.com很糟糕.这意味着它不存在.我怎样才能在我的项目中实现相同的功能?

欢迎使用javascript,jquery shell脚本,c或c ++.没有.net.

email

3
推荐指数
3
解决办法
1万
查看次数

通过KeyError在python中迭代xml

我的 XML :

<books>
<book name="goodbook" cost="10" color="green"></book>
<book name="badbook" cost="1000" weight="100"></book>
<book name="avgbook" cost="99" weight="120"></book>
</books>
Run Code Online (Sandbox Code Playgroud)

我的python代码:-

import xml.etree.ElementTree as ET
import sys
doc       = ET.parse("books.xml")
root      = doc.getroot() 
root_new  = ET.Element("books") 
for child in root:
       name                = child.attrib['name']
       cost                = child.attrib['cost']
       color               = child.attrib['color'] #KeyError
       weight              = child.attrib['weight'] #KeyError
       # create "book" here
       book    = ET.SubElement(root_new, "book") 
       book.set("name",name)               
       book.set("cost",cost) 
       book.set("color",color) 
       book.set("weight",weight)
tree = ET.ElementTree(root_new)
tree.write(sys.stdout)
Run Code Online (Sandbox Code Playgroud)

出现什么错误:-

python books.py 
Traceback (most recent call last):
  File "books.py", line 10, in …
Run Code Online (Sandbox Code Playgroud)

python

3
推荐指数
1
解决办法
4112
查看次数

如何在python中将基于函数的程序转换为类概念

我有一个程序,但它不包含类概念(Python 程序遵循类概念的一些价值)实际上是 Python 世界中的一个新程序。所以从原始的方式学习帮助我在这个世界上闪耀。任何人都可以帮助我,而不是给这个问题打负分:(

 import xml.etree.ElementTree as ET
 import sys

doc       = ET.parse("books.xml")
root      = doc.getroot() 
root_new  = ET.Element("books") 
for child in root:
    name                = child.attrib['name']
    cost                = child.attrib['cost']
    # create "book" here
    book    = ET.SubElement(root_new, "book") 
    book.set("name",name)               
    book.set("cost",cost) 
    if 'color' in child.attrib:
        color               = child.attrib['color']
        book.set("color",color) 
    if 'weight' in child.attrib:
        weight              = child.attrib['weight']
        book.set("weight",weight)
    for g in child.findall("cover"):
        # create "group" here
       cover     = ET.SubElement(cover,"cover")  
        if g.text != "goldcover":
            cover.text = g.text 
tree = ET.ElementTree(root_new)
tree.write(sys.stdout)
Run Code Online (Sandbox Code Playgroud)

为了理解:我的 xml 是, …

python

0
推荐指数
1
解决办法
645
查看次数

标签 统计

python ×2

email ×1