基本信息
文件名称:Python基础与大数据应用(第2版)(微课版) 试卷及答案5.docx
文件大小:27.14 KB
总页数:8 页
更新时间:2025-06-25
总字数:约5.34千字
文档摘要

Python综合应用测试卷(五)

一、单项选择题(每题3分,共45分)

在Python中,使用requests库发送HTTP请求时,用于发送GET请求的方法是()

A.?requests.post()?B.?requests.get()?C.?requests.put()?D.?requests.delete()

假设要从网页中提取所有的链接,在Python中使用BeautifulSoup库时,以下代码正确的是()

A.

frombs4importBeautifulSoup

importrequests

response=requests.get(网页URL)

soup=BeautifulSoup(response.text,html.parser)

links=soup.find_all(a)

B.

frombs4importBeautifulSoup

importrequests

response=requests.get(网页URL)

soup=BeautifulSoup(response.content,html.parser)

links=soup.find_all(link)

C.

frombs4importBeautifulSoup

importrequests

response=requests.post(网页URL)

soup=BeautifulSoup(response.text,html.parser)

links=soup.find_all(a)

D.

frombs4importBeautifulSoup

importrequests

response=requests.get(网页URL)

soup=BeautifulSoup(response.text,xml)

links=soup.find_all(a)

在Python中,连接MySQL数据库通常使用的库是()

A.?sqlite3?B.?pymysql?C.?psycopg2?D.?mysqlclient

以下关于SQL语句的说法,错误的是()

A.?SELECT语句用于查询数据B.?INSERTINTO语句用于插入数据

C.?UPDATE语句用于删除数据D.?DELETEFROM语句用于删除数据

执行以下Python代码连接MySQL数据库,正确的是()

A.

importpymysql

conn=pymysql.connect(host=localhost,user=root,password=password,database=test)

B.

importpymysql

conn=pymysql.connect(server=localhost,user=root,password=password,database=test)

C.

importpymysql

conn=pymysql.connect(host=localhost,username=root,password=password,database=test)

D.

importpymysql

conn=pymysql.connect(host=localhost,user=root,passwd=password,db=test)

在爬虫开发中,设置请求头(headers)的主要目的是()

A.提高请求速度B.模拟浏览器访问,避免被网站拒绝

C.隐藏请求的参数D.压缩请求数据

以下关于数据库事务的说法,正确的是()

A.事务是一组不可分割的数据库操作,要么全部执行成功,要么全部失败回滚

B.事务只能包含一条SQL语句

C.事务不需要提交就会生效

D.事务在数据库连接断开时会自动提交

在Python中,使用lxml库解析HTML文档时,以下哪种方式可以获取文档中所有的div标签()

A.

fromlxmlimportetree

html=etree.HTML(html文档内容)

divs=html.xpath(//div)

B.

fromlxmlimportetree

html=etree.HTML(html文档内容)

divs=html.find_all(div)

C.

fromlxmlimportetree

html=etree.parse(html文档内容)

divs=html.xpath(//div)

D.

fromlxmlimportetree

html=etree.parse