Python学习记录之语法(一)

1.from...import         import...as的意思

from os import makedirs, unlink, sep   #从os包中引入 makedirs.unlink,sep类

from os.path import dirname, exists, isdir, splitext  从 os包中的path类中引入 dirmame exists 等方法
import urllib.request   //引入 urllib resquest包
from urllib.parse import urlparse 
from sys import argv 

import html.parser as h   #给包html.parser 定义一个h别名

2.输出系统当前时间、

                import datetime as dt #给detetime包定义一个别名 dt

                print(dt.datetime.now())

3.urllib2.urlopen()的使用,用来从网上获取信息。

            在python3中urllib和urllib2集合一个包了,就是urllib.request包。

                        import urllib.request

                        resp=urllib.request.urlopen("http://www.baidu.com")


猜你喜欢

转载自blog.csdn.net/qq_26658517/article/details/80940485
今日推荐