瀏覽單個文章
barboo0412
Major Member
 
barboo0412的大頭照
 

加入日期: May 2001
您的住址: 台北
文章: 130
版上有沒有python的高手呢?

最近在學習python , 萬事起頭難..

#! /usr/bin/env Python
#!coding=utf-8
import smtplib
import random
import dns.resolver
answers = dns.resolver.query('yahoo.com.tw', 'MX')
host = "0"
newhost = "0"
port = "25"
for rdata in answers:
host = (rdata.exchange)
print host
if host != "0":
break
#print host
#print 'Host', rdata.exchange, 'has preference', rdata.preference
smtp=smtplib.SMTP()
smtp.connect(host, port)

這個是取得domain mx 的一段, print host 是正確的, (mx-tw.mail.gm0.yahoodns.net.)
但在 len(host)時得到的是 6, 似乎變成陣列了.

所以在smtp.connect(host, port) 給的值就不對.
應該要怎麼處理呢?
     
      
__________________
舊 2014-02-28, 03:12 PM #1
回應時引用此文章
barboo0412離線中