Python 第3页
上课笔记以及平时作业记录

Python_24.6.7_mysql插入

import pymysql # 建立数据库连接 db = pymysql.connect(host='localhost', user='root', password='123456', db='stu') cursor = db.cursor() # 创建学生表的SQL语句(注释掉了,因为表如果已...
北梦的头像-北梦の博客SVIP北梦1年前
0321

python-模板-6-11

import pymysql #1.创建学生表,插入两条数据 #数据库连接 conn=pymysql.connect(host='localhost',user='root',password='123456789',db='world') cursor=conn.cursor() # create_sql='''creat...
iu不错哦的头像-北梦の博客iu不错哦12个月前
0151

Python-pymysql建表

import pymysql zwy = pymysql.connect(host='localhost', user='root', password='123456789', db='world') cursor = zwy.cursor() create_sql = '''create table student ( sid char(10), sna...
珊瑚海的头像-北梦の博客珊瑚海12个月前
0181

Python-pymysql插入

import pymysql zwy = pymysql.connect(host='localhost', user='root', password='123456789', db='world') cursor = zwy.cursor() insert_many_sql = [('01', 'zwy', 'n'), ('02', 'yxj', 'n'...
珊瑚海的头像-北梦の博客珊瑚海12个月前
0131

Python-pymysql修改

import pymysql zwy = pymysql.connect(host='localhost', user='root', password='123456789', db='world') cursor = zwy.cursor() zwy.commit() update_sql = '''update student set sname = ...
珊瑚海的头像-北梦の博客珊瑚海12个月前
0171

Python-pymysql删除

import pymysql zwy = pymysql.connect(host='localhost', user='root', password='123456789', db='world') cursor = zwy.cursor() zwy.commit() delete_sql = 'delete from student where sna...
珊瑚海的头像-北梦の博客珊瑚海12个月前
0271

Python_模拟银行对接mysql_24.6.14

1.创建数据库和数据表 import pymysql CREATE_SCHEMA_SQL = 'CREATE SCHEMA bank' CREATE_TABLE_SQL = '''CREATE TABLE account( account_id varchar(20) not null, account_passwd char(6) not...
北梦的头像-北梦の博客SVIP北梦12个月前
0441

Python上课笔记

编写列表推导式1、将一组数字列表[1,2,3,4,5,6,7,8],每个数字都平方并除以2.l1 = [1, 2, 3, 4, 5, 6, 7, 8] print([i * i / 2 for i in l1])2、将一组字符串列表['apple','banana','cherry'],...
北梦的头像-北梦の博客SVIP北梦2年前
12571

python_小作业_24.6.20

1.定义一个Box类,有width, height, depth三个属性,init()和get_Volume()(求体积)两个方法。其中init()方法用于获得初始化属性值,width, height, depth分别为5,6,7. (1)定义get_Volume()...
北梦的头像-北梦の博客SVIP北梦12个月前
0251

python_练习_mysql_24.6.6

import pymysql db = pymysql.connect( host='localhost', user='root', password='123456789', db='world' ) cursor = db.cursor() sql = '''CREATE TABLE zhangsan ( sno CHAR(10) PRIMARY KE...
北梦的头像-北梦の博客SVIP北梦1年前
0191