20006 基于python的海鲜商城系统
运行视频、代码等:
链接:https://pan.baidu.com/s/1tw4Qvtcuwt7ys36M7HvLSg
提取码:1589
复制这段内容后打开百度网盘手机App,操作更方便哦
技术
Python + Django+ Bootsatrp + MySQL
功能详情
系统相关截图
`import time
def show_info():
print('''输入提示数字,执行相应操作
0:退出
1:查看登录日志
''')
def write_loginfo(username):
"""
将用户名和登录时间写入日志
:param username: 用户名
"""
with open('log.txt','a') as f:
string = "用户名:{} 登录时间:{}\n".format(username ,time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())))
f.write(string)
def read_loginfo():
"""
读取日志
"""
with open('log.txt','r') as f:
while True:
line = f.readline()
if line == '':
break # 跳出循环
print(line) # 输出一行内容
if name == "main":
# 输入用户名
username = input('请输入用户名:')
# 检测用户名
while len(username) < 2 :
print('用户名长度应不少于2位')
username = input('请输入用户名:')
# 输入密码
password = input('请输入密码:')
# 检测密码
while len(passw ord) < 6 :
print('密码长度应不少于6位')
password = input('请输入密码:')
print('登录成功')
write_loginfo(username) # 写入日志
show_info() # 提示信息
num = int(input('输入操作数字:')) # 输入数字
while True:
if num == 0:
print('退出成功')
break
elif num == 1:
print('查看登录日志')
read_loginfo()
show_info()
num = int(input('输入操作数字:'))
else:
print('您输入的数字有误')
show_info()
num = int(input('输入操作数字:'))`
3 def find_answer(question): 4 with open('reply.txt','r') as f : 5 while True: 6 line=f.readline() 7 if not line: #也可以为if line=='' 8 break 9 keyword=line.split('|')[0] 10 reply=line.split('|')[1] 11 if keyword in question: 12 return reply 13 return '对不起,没有你想要找的问题' 14 15 if __name__ =='__main__': 16 question=input('请输入想要提问的内容:') 17 while True: 18 if question=='bye': 19 break 20 reply=find_answer(question) 21 if not reply: 22 question=input("小蜜不懂您在说什么,您可以问一些与订单、账户和支付相关的内容(退出请输入bye):") 23 else: 24 print(reply) 25 question=input("您可以问一些与订单、账户和支付相关的内容(退出请输入bye):") 26 print('谢谢,再见!') 27 1 import re 2 str_test='abcdefgHABC123456中华民族' 3 4 #把正则表达式编译成对象,如果经常使用该对象,此种方式可提高一定效率 5 num_regex = re.compile(r'[0-9]') 6 zimu_regex = re.compile(r'[a-zA-z]') 7 hanzi_regex = re.compile(r'[\u4E00-\u9FA5]') 8 9 print('输入字符串:',str_test) 10 #findall获取字符串中所有匹配的字符 11 num_list = num_regex.findall(str_test) 12 print('包含的数字:',num_list) 13 zimu_list = zimu_regex.findall(str_test) 14 print('包含的字母:',zimu_list) 15 hanzi_list = hanzi_regex.findall(str_test) 16 print('包含的汉字:',hanzi_list)
1 import random as r 2 3 #总次数 4 total=1000000 #1000,1W,10W,100W 5 #换与不换的获胜次数 6 win1=0 7 win2=0 8 9 for i in range(total): 10 #模拟选择过程 11 man=r.randint(1,3) 12 car=r.randint(1,3) 13 #结果:一开始为车门,不换+1. 14 # 否则则一开始为羊门,换+1. 15 if man==car: 16 win1+=1 17 else: 18 win2+=1 19 20 print("在{}次实验中:".format(total)) 21 print("若不更改门,获胜概率为{:.3}%.".format((win1/total)*100)) 22 print("若更改门,获胜概率为{:.3}%.".format((win2/total)*100))
`import sqlite3
def create():
conn=sqlite3.connect('test.db')
cu=conn.cursor()
cu.execute('create table stuinfo if not exit(no varchar(10) primary key,name varchar(20),sex varchar(20),height varchar(20),weight varchar(20))')
cu.close()
conn.commit()
conn.close()
def add():
conn=sqlite3.connect('test.db')
cu=conn.cursor()
myinput=[]
info=['学号','姓名','性别','身高','体重']
for i in range(5):
myinput.append(input('%s'%info[i]))
cu.execute('insert into stuinfo values(?,?,?,?,?)',(myinput[0],myinput[1],myinput[2],myinput[3],myinput[4]))
cu.close()
conn.commit()
conn.close()
def select(no):
conn=sqlite3.connect('test.db')
cu=conn.cursor()
a=cu.execute('select height from stuinfo where id=?',(no,))
vlaue=a.fetchall()
print(vlaue[0][0])
cu.close()
conn.close()`