Python面试题:如何用Python来发送邮件
可以使用smtplib标准库。
以下代码可以在支持SMTP监听器的服务器上执行。
import sys, smtplib
fromaddr = raw_input(“From: “)
toaddrs = raw_input(“To: “).split(‘,’)
print “Enter message, end with ^D:”
msg = ”
while 1:
line = sys.stdin.readline()
if not line:
break
msg = msg + line
# 发送邮件部分
server = smtplib.SMTP(‘localhost’)
server.sendmail(fromaddr, toaddrs, msg)
server.quit()
以下代码可以在支持SMTP监听器的服务器上执行。
import sys, smtplib
fromaddr = raw_input(“From: “)
toaddrs = raw_input(“To: “).split(‘,’)
print “Enter message, end with ^D:”
msg = ”
while 1:
line = sys.stdin.readline()
if not line:
break
msg = msg + line
# 发送邮件部分
server = smtplib.SMTP(‘localhost’)
server.sendmail(fromaddr, toaddrs, msg)
server.quit()
【Python面试题:如何用Python来发送邮件】相关文章
5. 如何用PHP实现邮件发送
7. 华为python面试题
8. Python面试题集
9. 软件测试LoadRunner面试题:What is think time? How do you change the threshold?
10. 用Python匹配HTML tag的时候,<.*>和<.*?>有什么区别
本文来源:https://www.mianshiwenti.com/a13497.html
进入下载页面
﹝Python面试题:如何用Python来发送邮件﹞相关内容
- 用Python写一个for循环的例子
- 请用Python写一个获取用户输入数字,并根据数字大小输出不同信息的脚本
- Python的两道面试题
- Python文件操作的面试题
- 软件测试LoadRunner面试题:If you want to stop the execution of your script on error, how do you do that?
- 软件测试LoadRunner面试题:How did you plan the Load? What are the Criteria?
- Python里面如何拷贝一个对象
- Python中如何定义一个函数
- Python是如何进行类型转换的
- Python里面如何实现tuple和list的转换