Python daily delicious (21)-httplib, smtplib

Source: Internet
Author: User
Example 1: Use httplib to access a URL and obtain the returned content:

Import Httplib

Conn = Httplib. httpconnection ( " Www.cnblogs.com " )
Conn. Request ( " Get " , " /Coderzh/archive/2008/05/13/1194445 .html " )
R = Conn. getresponse ()
Print R. Read () # Get all content

Example 2: Use smtplib to send an email

Import Smtplib
Smtpserver =   ' Smtp.xxx.com '
Fromaddr =   ' Foo@xxx.com '
Toaddrs =   ' Your@xxx.com '
MSG =   ' Subject: XXXXXXXXX '
Server = Smtplib. SMTP (smtpserver)
Server. Sendmail (fromaddr, toaddrs, MSG)
Server. Quit ()

Python daily delicious series (total)

Python daily delicious (19)-time processing datetime

Python daily delicious (20)-command line parameter SYS. argv

Python daily delicious (21)-httplib, smtplib

Python daily delicious (22)-copy object (deep copy deepcopy and light copy)

Python daily delicious (23)-enumerate traversing Arrays

...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.