File tree 1 file changed +6
-6
lines changed
1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -178,13 +178,13 @@ protocols. Two of the simplest are :mod:`urllib.request` for retrieving data
178
178
from URLs and :mod: `smtplib ` for sending mail::
179
179
180
180
>>> from urllib.request import urlopen
181
- >>> with urlopen('http://tycho.usno.navy.mil/cgi-bin/timer.pl ') as response:
181
+ >>> with urlopen('http://worldtimeapi.org/api/timezone/etc/UTC.txt ') as response:
182
182
... for line in response:
183
- ... line = line.decode('utf-8' ) # Decoding the binary data to text.
184
- ... if 'EST' in line or 'EDT' in line: # look for Eastern Time
185
- ... print(line)
186
-
187
- <BR>Nov. 25, 09:43:32 PM EST
183
+ ... line = line.decode() # Convert bytes to a str
184
+ ... if line.startswith('datetime'):
185
+ ... print(line.rstrip()) # Remove trailing newline
186
+ ...
187
+ datetime: 2022-01-01T01:36:47.689215+00:00
188
188
189
189
>>> import smtplib
190
190
>>> server = smtplib.SMTP('localhost')
You can’t perform that action at this time.
0 commit comments