时间和日期-python3.2.3官方文档(中文版)高清完整pdf
7.7互联网访问Python中有许多访问互联网和处理互联网协议的模块。其中最简单的两个就是从链接中获得数据的urllib.request和发送邮件的smtplib. >>> from urllib.request import urlopen >>> for line in urlopen(’http://tycho.usno.navy.mil/cgi-bin/timer.pl’): ... line = line.decode(’utf-8’) # Decoding the binary data to text. ... if ’EST’ in line or ’EDT’ in line: # look for Eastern Time ... print(line) Nov. 25, 09:43:32 PM EST >>> import smtplib >>> server = smtplib.SMTP(’localhost’) >>> server.sendmail(’soothsayer@example.org’, ’jcaesar@example.org’, ... """To: jcaesar@example.org ... From: soothsayer@example.org ... Beware the Ides of March. ... """) >>> server.quit() (注意第二个例子需要有一个在本地运行的email邮箱服务器) 7.8时间和日期Datatime模块提供一些用简单或复杂方式处理时间和日期的类。当处理日期和时间数据时,
1.32MB
文件大小:
评论区