2020 自动化工程开发python(新疆天山职业技术学院(本科)) 最新满分章节测试答案
本答案对应课程为:点我自动跳转查看
本课程起止时间为:2020-05-06到2020-06-30
本篇答案更新状态:已完结
项目1 爬取学生信息 测验1
1、 问题:class StudentDB: def openDB(self): self.con=sqlite3.connect(“students.db”) self.cursor=self.con.cursor() def closeDB(self): self.con.commit() self.con.close() def initTable(self): res={} try: self.cursor.execute(“create table students (No varchar(16) primary key,Name varchar(16), Sex varchar(8), Age int)”) res[“msg”]=”OK” except Exception as err: res[“msg”]=str(err) return res def updateRow(self,No,Name,Sex,Age): res={} try: _______ res[“msg”]=”OK” except Exception as err: res[“msg”]=str(err) return res程序修改一条学生记录,缺失的语句是
选项:
A:self.cursor.execute(“update students set Name=%s,Sex=%s,Age=%s where No=%s”,(Name,Sex,Age,No))
B:self.cursor.execute(“update students set Name=%s,Sex=%s,Age=%s where No=%d”,(Name,Sex,Age,No))
C:self.cursor.execute(“update students set Name=?,Sex=?,Age=? where No=?”,(Name,Sex,Age,No))
D:self.cursor.execute(“update students set Name=%,Sex=%,Age=% where No=%”,(Name,Sex,Age,No))
答案: 【self.cursor.execute(“update students set Name=?,Sex=?,Age=? where No=?”,(Name,Sex,Age,No))】
2、 问题:编程客户端client.py程序如下:import urllib.parseimport urllib.requesturl=”http://127.0.0.1:5000″try: province= urllib.parse.quote(“广东”) city= urllib.parse.quote(“深圳”) data=”province=”+province+”&city=”+city _____ ____ html = html.read() html = html.decode() print(html)except Exception as err: print(err)服务器server.py程序import flaskapp=flask.Flask(name__)@app.route(“/”,methods=[“POST”])def index(): try: province=flask.request.form.get(“province”) if ”province” in flask.request.form else ”” city = flask.request.form.get(“city”) if ”city” in flask.request.form else ”” return province+”,”+city except Exception as err: return str(err)if name==”main“: app.run()缺失的语句是
选项:
A:data=data.decode();html=urllib.request.urlopen(“http://127.0.0.1:5000″,data=data)
B:data=data.encode();html=urllib.request.urlopen(“http://127.0.0.1:5000″,data=data)
C:data=data.encode();html=urllib.request.urlopen(“http://127.0.0.1:5000?data=”+data)
D:data=data.decode();html=urllib.request.urlopen(“http://127.0.0.1:5000?data=”+data)
答案: 【data=data.encode();html=urllib.request.urlopen(“http://127.0.0.1:5000″,data=data)】
3、 问题:class StudentDB: def openDB(self): self.con=sqlite3.connect(“students.db”) self.cursor=self.con.cursor() def closeDB(self): self.con.commit() self.con.close() def initTable(self): res={} try: self.cursor.execute(“create table students (No varchar(16) primary key,Name varchar(16), Sex varchar(8), Age int)”) res[“msg”]=”OK” except Exception as err: res[“msg”]=str(err) return res def insertRow(self,No,Name,Sex,Age): res={} try: _______ res[“msg”]=”OK” except Exception as err: res[“msg”]=str(err) return res程序插入一条学生记录,缺失的语句是
选项:
A:self.cursor.execute(“insert into students (No,Name,Sex,Age) values (%s,%s,%s,%s)”,(No,Name,Sex,Age))
B:self.cursor.execute(“insert into students (No,Name,Sex,Age) values (%s,%s,%s,%d)”,(No,Name,Sex,Age))
C:self.cursor.execute(“insert into students (No,Name,Sex,Age) values (@No,@Name,@Sex,@Age)”,(No,Name,Sex,Age))
D:self.cursor.execute(“insert into students (No,Name,Sex,Age) values (?,?,?,?)”,(No,Name,Sex,Age))
答案: 【self.cursor.execute(“insert into students (No,Name,Sex,Age) values (?,?,?,?)”,(No,Name,Sex,Age))】
4、 问题:服务器程序接受客户端上传的文件名称fileName,然后获取文件数据保存import flaskapp=flask.Flask(name)@app.route(“/upload”,methods=[“POST”])def uploadFile(): msg=”” try: if ”fileName” in flask.request.values: fileName = flask.request.values.get(“fileName”) ______ fobj=open(“upload ”+fileName,”wb”) fobj.write(data) fobj.close() msg=”OK” else: msg=”没有按要求上传文件” except Exception as err: print(err) msg=str(err) return msgif name__==”main“: app.run()缺失的语句是
选项:
A:data=flask.request.read()
B:data=flask.request.get_data()
C:data=flask.request.values.read()
D:data=flask.request.values.get_data()
答案: 【data=flask.request.get_data()】
5、 问题:服务器程序可以接受get与post的提交信息import flaskapp=flask.Flask(name)@app.route(“/”,____)def index(): try: province=flask.request.values.get(“province”) if ”province” in flask.request.values else ”” city = flask.request.values.get(“city”) if ”city” in flask.request.values else ”” note = flask.request.values.get(“note”) if ”note” in flask.request.values else ”” return province+”,”+city+””+note except Exception as err: return str(err)if name__==”main“: app.run()缺失的语句是
选项:
A: methods=[“GET”,”POST”]
B:method=[“GET”,”POST”]
C: methods=[“POST”]
D:method=[“POST”]
答案: 【 methods=[“GET”,”POST”] 】
6、 问题:class StudentDB: def openDB(self): self.con=sqlite3.connect(“students.db”) self.cursor=self.con.cursor() def closeDB(self): self.con.commit() self.con.close() def initTable(self): res={} try: self.cursor.execute(“create table students (No varchar(16) primary key,Name varchar(16), Sex varchar(8), Age int)”) res[“msg”]=”OK” except Exception as err: res[“msg”]=str(err) return res def selectRows(self): res={} try: data=[] _______ _______ for row in rows: d={} d[“No”]=row[0] d[“Name”]=row[1] d[“Sex”]=row[2] d[“Age”]=row[3] data.append(d) res[“msg”]=”OK” res[“data”]=data except Exception as err: res[“msg”]=str(err) return res从数据库中读出所有学生记录,缺失的语句是
选项:
A:self.cursor.execute(“select * from students order by No”);rows=self.cursor.fetchall()
B:self.con.execute(“select * from students order by No”);rows=self.con.fetchall()
C:self.cursor.execute(“select * from students order by No”);rows=self.cursor.fetch()
D:self.con.execute(“select * from students order by No”);rows=self.con.fetch()
答案: 【self.cursor.execute(“select * from students order by No”);rows=self.cursor.fetchall()】
7、 问题:class StudentDB: def openDB(self): self.con=sqlite3.connect(“students.db”) self.cursor=self.con.cursor() def closeDB(self): self.con.commit() self.con.close() def initTable(self): res={} try: self.cursor.execute(“create table students (No varchar(16) primary key,Name varchar(16), Sex varchar(8), Age int)”) res[“msg”]=”OK” except Exception as err: res[“msg”]=str(err) return res def deleteRow(self,No): res={} try: __________ res[“msg”]=”OK” except Exception as err: res[“msg”]=str(err) return res程序删除一条学生记录,缺失的语句是
选项:
A:self.cursor.execute(“delete from students where No=?”,(No))
B:self.cursor.execute(“delete from students where No=?”,(No,))
C:self.cursor.execute(“delete from students where No=%s”,(No,))
D:self.cursor.execute(“delete from students where No=%s”,(No))
答案: 【self.cursor.execute(“delete from students where No=?”,(No,))】
8、 问题:服务器程序可以下载文件”图像.jpg”import flaskimport osapp=flask.Flask(name)@app.route(“/”)def index(): if ”fileName” not in flask.request.values: return ”图像.jpg” else: data = b”” try: ______ if fileName != ”” and os.path.exists(fileName): fobj = open(fileName, ”rb”) ____ fobj.close() except Exception as err: data = str(err).encode() return dataif name==”main“: app.run()缺失的语句是
选项:
A:fileName = flask.request.values.get(“fileName”); data = fobj.read()
B:fileName = flask.request.args.get(“fileName”); data = fobj.read()
C:fileName = flask.request.form.get(“fileName”); data = fobj.read()
D:都不对
答案: 【fileName = flask.request.values.get(“fileName”); data = fobj.read()】
9、 问题:import res=”testing search”reg=r”[A-Za-z]+\b”m=re.search(reg,s)while m!=None: start=m.start() end=m.end() print(s[start:end],end=” ”) s=s[end:] m=re.search(reg,s)结果:
选项:
A:testing
B:testing search
C:search
D:search testing
答案: 【testing search】
10、 问题:编写服务器程序server.py如下:import flaskapp=flask.Flask(name)@app.route(“/”)def index(): try: province=flask.request.args.get(“province”) city = flask.request.args.get(“city”) return province+”,”+city except Exception as err: return str(err)if name==”main“: app.run()编写客户端程序client.py如下:import urllib.parseimport urllib.requesturl=”http://127.0.0.1:5000″try: province= urllib.parse.quote(“广东”) city= urllib.parse.quote(“深圳”) data=”province=”+province+”&city=”+city html=urllib.request.urlopen(“http://127.0.0.1:5000?”+data) ________ html = html.decode() print(html)except Exception as err: print(err)缺失的语句是
选项:
A:html=html.read()
B:html.read()
C:html=html.get()
D:html.get()
答案: 【html=html.read()】
11、 问题:import rereg=r”x[^ab0-9]y”m=re.search(reg,”xayx2yxcy”)print(m)结果匹配”xcy”:<_sre.SRE_Match object; span=(6, 9), match=’xcy’>
选项:
A:正确
B:错误
答案: 【正确】
12、 问题:import rereg=r”x[0-9]y”m=re.search(reg,”xyx2y”)print(m)结果匹配”x2y”:<_sre.SRE_Match object; span=(0, 2), match=’xy’>
选项:
A:正确
B:错误
答案: 【错误】
13、 问题:import rereg=r”car\b”m=re.search(reg,”The car is black”)print(m)结果匹配”car”,因为”car”后面是以个空格:<_sre.SRE_Match object; span=(4, 7), match=’car’>
选项:
A:正确
B:错误
答案: 【正确】
14、 问题:import rereg=r”ab?”m=re.search(reg,”cabcabc”)print(m)结果匹配”a\b”:<_sre.SRE_Match object; span=(1, 4), match=’ab’>
选项:
A:正确
B:错误
答案: 【错误】
15、 问题:import res=”xaabababy”m=re.search(r”ab|ba”,s)print(m)结果匹配”ab”或者”ba”都可以:<_sre.SRE_Match object; span=(2, 4), match=’ba’>
选项:
A:正确
B:错误
答案: 【错误】
16、 问题:import res=”xaxby”m=re.search(r”a.b”,s)print(m)结果”.”代表了字符”x”<_sre.SRE_Match object; span=(1, 4), match=’axb’>
选项:
A:正确
B:错误
答案: 【正确】
17、 问题:import rereg=r”ab?”m=re.search(reg,”abbcabc”)print(m)结果:<_sre.SRE_Match object; span=(0, 3), match=’abb’>
选项:
A:正确
B:错误
答案: 【错误】
18、 问题:import rereg=r”ab+”m=re.search(reg,”acabc”)print(m)reg=r”ab*”m=re.search(reg,”acabc”)print(m)结果:<_sre.SRE_Match object; span=(2, 4), match=’ab’><_sre.SRE_Match object; span=(2, 4), match=’ab’>
选项:
A:正确
B:错误
答案: 【错误】
19、 问题:import rereg=r”b\d+”m=re.search(reg,”a12b123c”)print(m)结果找到了”b123″:<_sre.SRE_Match object; span=(3, 7), match=’b123′>
选项:
A:正确
B:错误
答案: 【正确】
20、 问题:import rereg=r”\d”m=re.search(reg,”abc123cd”)print(m)结果找到了第一个数值”1″:<_sre.SRE_Match object; span=(3, 4), match=’1′>
选项:
A:正确
B:错误
答案: 【正确】
项目2 爬取天气预报数据 测验2
1、 问题:from bs4 import BeautifulSoupdoc=”’
The Dormouse’s story
Once upon a time there were three little sisters; and their names wereElsie,Lacie andTillie;and they lived at the bottom of a well.
…
”’soup=BeautifulSoup(doc,”lxml”)_______print(tag)程序结果找到class=”story”的
元素,缺失的语句是
选项:
A:tag=soup.find(“p”,attrs={“class”:”story”})
B:tag=soup.find(“p”,attr={“class”:”story”})
C:tag=soup.find(“p”)
D:tag=soup.find(“p”,class=”story”)
答案: 【tag=soup.find(“p”,attrs={“class”:”story”})】
2、 问题:from bs4 import BeautifulSoupdoc=”’
The Dormouse’s story
Once upon a time there were three little sisters; and their names wereElsie,Lacie andTillie;and they lived at the bottom of a well.
…
”’soup=BeautifulSoup(doc,”lxml”)_____for tag in tags: print(tag)查找文档中class=”sister”的元素,缺失语句是:
选项:
A:tags=soup.find(name=None,attrs={“class”:”sister”})
B:tags=soup.find(attrs={“class”:”sister”})
C:tags=soup.find_all(attrs={“class”:”sister”})
D:tags=soup.find_all(name=None,attrs={“class”:”sister”})
答案: 【tags=soup.find_all(name=None,attrs={“class”:”sister”})】
3、 问题:查找文档中所有超级链接地址from bs4 import BeautifulSoupdoc=”’
The Dormouse’s story
Once upon a time there were three little sisters; and their names wereElsie,Lacie andTillie;and they lived at the bottom of a well.
…
”’soup=BeautifulSoup(doc,”lxml”)____for tag in tags: _____缺失的语句是:
选项:
A:tags=soup.find_all(“a”);print(tag.href)
B:tags=soup.find_all(“a”);print(tag(“href”))
C:tags=soup.find(“a”);print(tag[“href”]);
D:tags=soup.find(“a”);print(tag.(“href”))
答案: 【tags=soup.find(“a”);print(tag[“href”]);】
4、 问题:查找文档中所有超级链接包含的文本值from bs4 import BeautifulSoupdoc=”’
The Dormouse’s story
Once upon a time there were three little sisters; and their names wereElsie,Lacie andTillie;and they lived at the bottom of a well.
…
”’soup=BeautifulSoup(doc,”lxml”)_____for tag in tags: ______缺失的语句是:
选项:
A:tags=soup.find_all(“a”); print(tag.text)
B:tags=soup.find(“a”); print(tag.text)
C:tags=soup.find_all(“a”); print(tag[“text”])
D:tags=soup.find_all(“a”); print(tag.text)
答案: 【tags=soup.find_all(“a”); print(tag.text)】
5、 问题:查找文档中所有
超级链接包含的文本值from bs4 import BeautifulSoupdoc=”’
The Dormouse’s story
Once upon a time there were three little sisters; and their names wereElsie,Lacie andTillie;and they lived at the bottom of a well.
…
”’soup=BeautifulSoup(doc,”lxml”)______for tag in tags: ____缺失的语句是:
选项:
A:tags=soup.find(“p”); print(tag.text)
B:tags=soup.find(“p”); print(tag[“text”])
C:tags=soup.find_all(“p”); print(tag.text)
D:tags=soup.find_all(“p”); print(tag[“text”])
答案: 【tags=soup.find_all(“p”); print(tag.text)】
本文章不含期末不含主观题!!
本文章不含期末不含主观题!!
支付后可长期查看
有疑问请添加客服QQ 2356025045反馈
如遇卡顿看不了请换个浏览器即可打开
请看清楚了再购买哦,电子资源购买后不支持退款哦