复习补作业 客户端服务端上传下载功能
客户端

import os import json import socket # cilent=socket.socket()#默认tcp传输 cilent.connect(('127.0.0.1',8080)) while True: dic_enum={'1':'file_update',2:'file_down'} for k,v in dic_enum.items(): print(k,v) functiom_num=input('请输入你需要的功能') if functiom_num=='1': #上传功能 dic={'fct':dic_enum.get(functiom_num),'file_name':None,'content':None} file_daar=input('请输入你要上传文件的绝对路劲》》》:') filename=os.path.basename(file_daar) with open(file_daar,'r',encoding='utf8')as f: content_info=f.read() dic['file_name']=filename dic['content']=content_info str_dic=json.dumps(dic) cilent.send(str_dic.encode('utf8')) elif functiom_num=='2': #下载功能 pass else: print('输入错误请重新输入') continue

conn,addr=server.accept() client_info=conn.recv(1024) str_dic=client_info.decode('utf8') dic=json.loads(str_dic) print(dic) #{"fct": "file_update", "file_name": "02.py", "content": "# #\u5185\u5b58\u5b58\u50a8\u8fc7\u7a0b\n# import pymysql\n# conn=pymysql.connect(\n# host='127.0.0.1',\n# port=3306,\n# user='root',\n# passwd='root',\n# db='da48',\n# charset='utf8',\n# autocommit=True #\u9ed8\u8ba4false \u4fee\u8be5\u540e\u9ed8\u8ba4\u786e\u8ba4\n#\n# )\n# cursor=conn.cursor(cursor=pymysql.cursors.DictCursor)\n# lambda"} #判断文件的要求是 if dic.get('fct')=='file_update': #创建储存文件 file_name='1'+dic.get('file_name') file_name_new=os.path.join('D:\internetreview\socket上传下载代码(补作业)\上传的文件夹',file_name) with open(file_name_new,'w',encoding='utf8')as f: f.write(dic['content']) if dic.get('fct')=='dile_down': pass
数据库作业

\# 班级表
cid caption
\# 学生表
sid sname gender class_id
\# 老师表
tid tname
\# 课程表
cid cname teacher_id
\# 成绩表
sid student_id course_id number
create table class(cid int primary key auto_increment,
caption char(10) not null );
create table students(sid int primary key auto_increment,
sname char(10)not NULL,
gender enum('female','male','other')default 'male',
class_id int,#外键
FOREIGN key(class_id) references class(cid));
create table teacher(tid int primary key auto_increment,
tname char(10)not null
);
create table teacher_class(
id int primary key auto_increment,
teacher_id int,
class_id int,
foreign key(class_id) REFERENCES class(cid),
foreign key(teacher_id) REFERENCES teacher(tid)
);
create table course(cid int primary key auto_increment,
cname char(10),
teacher_id int,
foreign key(teacher_id) references teacher(tid)
);
create table score(sid int primary key auto_increment,
student_id int ,
course_id int,
number int,
foreign key(student_id) references students(sid),
foreign key(course_id) references course(cid)
);

数据库作业2
复制代码
1. 查询岗位名以及岗位包含的所有员工名字
select post,group_concat(name) from emp group by post;
2. 查询岗位名以及各岗位内包含的员工个数
select post,count(id) from emp group by post;
3. 查询公司内男员工和女员工的个数
select sex,count(id) from emp group by sex;
4. 查询岗位名以及各岗位的平均薪资
select post,avg(salary) from emp group by post;
5. 查询岗位名以及各岗位的最高薪资
select post,max(salary) from emp group by post;
6. 查询岗位名以及各岗位的最低薪资
select post,min(salary) from emp group by post;
7. 查询男员工与男员工的平均薪资,女员工与女员工的平均薪资
select group_concat(name),sex,avg(salary) from emp group by sex