mirror of
https://github.com/python/cpython.git
synced 2025-10-30 13:11:29 +00:00
bpo-46079: Replace external link that is down for maintenance. (GH-30315) (GH-30329)
This commit is contained in:
parent
2d4049da1f
commit
72ffcb02f3
1 changed files with 6 additions and 6 deletions
|
|
@ -178,13 +178,13 @@ protocols. Two of the simplest are :mod:`urllib.request` for retrieving data
|
||||||
from URLs and :mod:`smtplib` for sending mail::
|
from URLs and :mod:`smtplib` for sending mail::
|
||||||
|
|
||||||
>>> from urllib.request import urlopen
|
>>> from urllib.request import urlopen
|
||||||
>>> with urlopen('http://tycho.usno.navy.mil/cgi-bin/timer.pl') as response:
|
>>> with urlopen('http://worldtimeapi.org/api/timezone/etc/UTC.txt') as response:
|
||||||
... for line in response:
|
... for line in response:
|
||||||
... line = line.decode('utf-8') # Decoding the binary data to text.
|
... line = line.decode() # Convert bytes to a str
|
||||||
... if 'EST' in line or 'EDT' in line: # look for Eastern Time
|
... if line.startswith('datetime'):
|
||||||
... print(line)
|
... print(line.rstrip()) # Remove trailing newline
|
||||||
|
...
|
||||||
<BR>Nov. 25, 09:43:32 PM EST
|
datetime: 2022-01-01T01:36:47.689215+00:00
|
||||||
|
|
||||||
>>> import smtplib
|
>>> import smtplib
|
||||||
>>> server = smtplib.SMTP('localhost')
|
>>> server = smtplib.SMTP('localhost')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue