在Python中存储print Whois的返回数据

在Python中存储print Whois的返回数据,python,email,whois,Python,Email,Whois,我有一个Python脚本: import whois w = whois.whois('google.com') print w 我想存储打印结果,然后通过电子邮件发送。您已经将结果存储在w下载中,以使发送电子邮件更加轻松 运行命令行pip安装yagmail 接下来,您可以轻松地向自己发送电子邮件,如: import yagmail import whois w = whois.whois('google.com') yag = yagmail.SMTP('yourusername@gm

我有一个Python脚本:

import whois 
w = whois.whois('google.com')
print w

我想存储打印结果,然后通过电子邮件发送。

您已经将结果存储在
w

下载中,以使发送电子邮件更加轻松

运行命令行
pip安装yagmail

接下来,您可以轻松地向自己发送电子邮件,如:

import yagmail
import whois 
w = whois.whois('google.com')

yag = yagmail.SMTP('yourusername@gmail.com', 'yourpasswrd')
yag.send(contents = str(w))
请注意,默认设置是发送给您自己,而不带
to
参数

如果您希望明确,可以执行以下操作:

yag.send('recipient@email.com', "this is the subject", str(w))

到目前为止,您尝试了什么?您可以在这里看到如何通过python发送电子邮件