2026年6月电子学会青少年软件编程(Python六级)等级考试试卷
客观题
六级
2026
2026-07-09 13:28:23
53次
一、单选题
下面代码的运行后输出JSON文件内容正确的是?( )
import json
stu = [{'name':“John”,'sex':“man”,“地址”:“渥太华”}]以Open(“stu.json”, “W”)作为输出文件:
json.dump(stu, outfile)
| A. [{'姓名':'约翰','性别':'男人','地址':'渥太华'}] |
B. {'名字':'约翰','性别':'男人','地址':'渥太华'} |
| C. ['名字':'约翰','性别':'男人','地址':'渥太华'] |
D. {['名字':'约翰','性别':'男人','地址':'渥太华']} |
【知识点】 电子学会Python六级
李华正在开发一个图书管理系统,使用SQLite数据库来存储图书信息。他需要编写代码来查询数据库,并根据不同的需求获取查询结果。假设他已经执行了一个查询语句来选择图书表(books)中的所有记录。现在,他面临三种不同的情况,每种情况需要使用不同的方法来获取数据:
1.获取查询结果的第一条记录。
2.获取查询结果的前三条记录。
3.获取查询结果中的所有记录。
请问,李华应该分别使用哪个游标对象的方法来满足上述每种情况的需求?( )
| A. fetchall()[0],fetchall[:3],fetchall() |
B. fetchfirst(),fetchfirst(3),fetchall() |
| C. fetchone(),fetchmany(3),fetchall() |
D. getone(),getmany(3),getall() |
【知识点】 电子学会Python六级
小明为学校图书馆的数据库编写一个查询,找出所有在2015年之后出版且评分超过8分的图书。图书信息存储在books表中,该表包括title(标题)、publish_year(出版年份)和rating(评分)等字段。以下哪个SQL查询语句最适合实现小明的需求?( )
| A. cursor.execute("SELECT title, publish_year FROM books WHERE publish_year > 2015 OR rating > 8") |
B. cursor.execute("SELECT title, publish_year FROM books WHERE publish_year > '2015' AND score > 8") |
| C. cursor.execute("SELECT title, publish_year FROM books WHERE year > '2015' AND rating > '8'") |
D. cursor.execute("SELECT title, publish_year FROM books WHERE publish_year > 2015 AND rating > 8") |
【知识点】 电子学会Python六级
执行以下Python代码后,文件output.txt中的内容是什么?( )
with open('output.txt', 'w') as f:
f.write('Line1\n')
f.write('Line2')
with open('output.txt', 'a') as f:
f.write('\nLine3') | A. Line1\nLine2\nLine3 |
B. Line1\nLine2Line3 |
| C. Line1Line2\nLine3 |
D. Line1\nLine2\nLine3\n |
【知识点】 电子学会Python六级
要将一个tk.Label组件的文本内容设置为“欢迎”,且字体为“宋体”,大小为12,正确的代码是?( )
| A. label = tk.Label(root, text="欢迎", font=("宋体", 12)) |
B. label = tk.Label(root, text="欢迎", font="宋体 12") |
| C. label = tk.Label(root, text="欢迎", font="12 宋体") |
D. label = tk.Label(root, text="欢迎", font=("宋体", "12")) |
【知识点】 电子学会Python六级







