测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A32422. 执行以下代码,数据表中共有几条数据? ( )import sqlite3 conn=sglite3.connect('student_info.db')cursor=conn.cursor()cursor.execute("'CREATE TABLE IF NOT EXISTS Student(id INTEGER PRIMARY KEY,name TEXT,age INTEGER)"')cur…

单选题 困难

题目描述

执行以下代码,数据表中共有几条数据? (    )

import sqlite3 

conn=sglite3.connect('student_info.db')

cursor=conn.cursor()

cursor.execute("'CREATE TABLE IF NOT EXISTS Student(id INTEGER PRIMARY KEY,name TEXT,age INTEGER)"')

cursor.execute("INSERT INTO Student(id,name,age)VALUES(1,'Alice',20)")

cursor.execute("INSERT INTO Student(id,name,age)VALUES(2,'Bob',22)")

cursor.execute("INSERT INTO Student(id,name,age)VALUES(3,'charlie',21)")

cursor.execute("SELECT * FROM Student")

students=cursor.fetchall()

for student in students: 

    print(f"ID:{student[0]},Name:{student[1]},Age:{student[2]}")

cursor.execute("UPDATE Student SET age=23 WHERE id=2")

cursor.execute("DELETE FROM Student WHERE id=3")

conn.commit()

conn.close()

选项(单选)

上一题 下一题