当前位置: 首页 > news >正文

做网站工资年新多少在广东aso苹果关键词优化

做网站工资年新多少在广东,aso苹果关键词优化,做网站官网,怎样做个做外贸的网站目标&#xff1a;本章讲解不同控件下&#xff0c; 数据在前端和后端之间的交互 控件有&#xff1a; 输入框 密码输入框 单选框 多选框 下拉框 多行文本框 不同控件中如何将数据传入后端&#xff1f;请看一下html代码 <!DOCTYPE html> <html> <head><meta …

目标:本章讲解不同控件下, 数据在前端和后端之间的交互

控件有:

  输入框

  密码输入框

  单选框

  多选框

  下拉框

  多行文本框

不同控件中如何将数据传入后端?请看一下html代码

<!DOCTYPE html>
<html>
<head><meta charset="UTF-8"><title>用户注册界面</title></head><body><form><!--账号输入控件--><div>用户名:<input type="text" placeholder="请输入用户名" name="user"/></div><div>密码:<input type="password" placeholder="请输入密码" name="pwd"/></div><!--单选框--><div>性别:男<input type="radio" name="sex" value="男"/>女<input type="radio" name="sex" value="女"/></div><!--多选框--><div>爱好:足球<input type="checkbox" name="爱好" value="1"/>篮球<input type="checkbox" name="爱好" value="2"/>兵乓球<input type="checkbox" name="爱好" value="3"/></div><!--下拉框--><div>所在城市:<select name="city"><option value="广西">广西</option><option value="广东">广东</option><option value="北京">北京</option></select></div><!--多行为本框--><div>其它信息:<textarea name="其它信息"></textarea></div><!--提交按钮--><div><input type="submit" value="提交" /></div></form></body>
</html>

然后在后端如何接收呢?数据接收四要素:(from表单、地址、传输方式、提交按钮)

 然后就可以通过函数接收进来了

# 注册成功后的界面逻辑
@app.route('/register_list')
def register_list():# 如果你想获取整个表单内容,则可以通过该方式datas = request.args# 如果你想单独获取某个数据,则可以通过该方式user = request.args.get('user')  # 用户名pwd = request.args.get('pwd')  # 密码sex = request.args.get('sex')  # 性别hobby = request.args.getlist('爱好')  # 爱好city = request.args.get('city')  # 城市other = request.args.get('其它信息')  # 其它print(user,pwd,sex,hobby,city,other)# 然后将数据传入数据库(这里暂时用文件代替)line = "{}|{}|{}\n".format(user,pwd,sex)  # 将数据以{用户名}|{密码}|{性别}这种数据格式展示file = open('db.txt',mode='a',encoding='utf-8')  # 创建文件流file.write(line)  # 写入文件file.close()  # 关闭文件return '注册成功'

那如何将获取到的数据展示到网站界面呢?变懒了,直接赋代码

render_template:转到到html界面

redirect:重定向接口

python代码

# -*- coding:utf-8 -*-
from flask import Flask, render_template, request, redirect# 创建 Flask 应用程序实例
app = Flask(__name__)# 注册界面逻辑
@app.route('/register')
def register():return render_template('register.html')# 注册成功后的界面逻辑
@app.route('/register_list')
def register_list():# 如果你想获取整个表单内容,则可以通过该方式datas = request.args# 如果你想单独获取某个数据,则可以通过该方式user = request.args.get('user')  # 用户名pwd = request.args.get('pwd')  # 密码sex = request.args.get('sex')  # 性别hobby = request.args.getlist('爱好')  # 爱好city = request.args.get('city')  # 城市other = request.args.get('其它信息')  # 其它# print(user, pwd, sex, hobby, city, other)# 然后将数据传入数据库(这里暂时用文件代替)line = "{}|{}|{}\n".format(user, pwd, sex)  # 将数据以{用户名}|{密码}|{性别}这种数据格式展示file = open('db.txt', mode='a', encoding='utf-8')  # 创建文件流file.write(line)  # 写入文件file.close()  # 关闭文件return redirect('/user_list')# 用户数据展示列表
@app.route('/user_list')
def user_list():# 从文件中读取数据:用户列表展示用file_list = []  # 创建一个列表,用户存储从文件读取到的数据file = open('db.txt', mode='r', encoding='utf-8')  # 创建文件流for i in file:file_list.append(i.strip())  # 去除开头和结尾的换行符, 再添加进列表file.close()  # 关闭文件print('这是列表', file_list)# 从文件中读取数据:用户表格展示用file_list_list = []  # 创建一个列表,用户存储从文件读取到的数据file_table = open('db.txt', mode='r', encoding='utf-8')  # 创建文件流for t in file_table:ts = t.strip().split('|')  # 去除开头和结尾的换行符, 然后再用 | 符号将数据分割开来file_list_list.append(ts)  # 再将数据添加进入列表file.close()  # 关闭文件print('这是表格', file_list_list)# 将数据展示到前端界面return render_template('user_list.html', v1=file_list, v2=file_list_list)# 运行应用程序
if __name__ == '__main__':app.run()
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>用户列表</title>
</head>
<body><h1>用户列表</h1>
<ul>{% for item in v1%}<li>{{item}}</li>{% endfor %}
</ul><h1>用户表格</h1>
<table border="1"><thead><tr><th>用户名</th><th>密码</th><th>性别</th></tr></thead><tbody>{% for item in v2%}<tr><td>{{item[0]}}</td><td>{{item[1]}}</td><td>{{item[2]}}</td></tr>{% endfor %}</tbody>
</table></body>
</html>

以上html代码运用到了for循环


文章转载自:
http://polyglottery.tgcw.cn
http://flakelet.tgcw.cn
http://seventeeth.tgcw.cn
http://rauwolfia.tgcw.cn
http://subalpine.tgcw.cn
http://entrainment.tgcw.cn
http://swimgloat.tgcw.cn
http://reinstatement.tgcw.cn
http://fidelista.tgcw.cn
http://disarm.tgcw.cn
http://guilin.tgcw.cn
http://citybred.tgcw.cn
http://beatrice.tgcw.cn
http://praise.tgcw.cn
http://sweetness.tgcw.cn
http://thermometry.tgcw.cn
http://megacephalous.tgcw.cn
http://attacca.tgcw.cn
http://couple.tgcw.cn
http://wormwood.tgcw.cn
http://phoebus.tgcw.cn
http://sanded.tgcw.cn
http://geranium.tgcw.cn
http://yantra.tgcw.cn
http://cushaw.tgcw.cn
http://undivulged.tgcw.cn
http://unforgettable.tgcw.cn
http://handmaiden.tgcw.cn
http://polygonize.tgcw.cn
http://narcotist.tgcw.cn
http://hoosegow.tgcw.cn
http://preciously.tgcw.cn
http://titicaca.tgcw.cn
http://udp.tgcw.cn
http://acetophenetide.tgcw.cn
http://haemolyze.tgcw.cn
http://vermiculation.tgcw.cn
http://morrow.tgcw.cn
http://termly.tgcw.cn
http://wearable.tgcw.cn
http://vaticinator.tgcw.cn
http://maladaptive.tgcw.cn
http://agrostology.tgcw.cn
http://turbid.tgcw.cn
http://oldie.tgcw.cn
http://saltglaze.tgcw.cn
http://taylorite.tgcw.cn
http://keratectomy.tgcw.cn
http://decimalise.tgcw.cn
http://mutation.tgcw.cn
http://hypersensitize.tgcw.cn
http://metaldehyde.tgcw.cn
http://heterogamy.tgcw.cn
http://racking.tgcw.cn
http://odalisk.tgcw.cn
http://causable.tgcw.cn
http://aftercrop.tgcw.cn
http://thymy.tgcw.cn
http://injectant.tgcw.cn
http://tartaric.tgcw.cn
http://lithuanian.tgcw.cn
http://dilatory.tgcw.cn
http://limewood.tgcw.cn
http://woodruffite.tgcw.cn
http://swore.tgcw.cn
http://dioptrics.tgcw.cn
http://boaz.tgcw.cn
http://exotericist.tgcw.cn
http://muscovitic.tgcw.cn
http://pinaceous.tgcw.cn
http://knacker.tgcw.cn
http://residua.tgcw.cn
http://toluidide.tgcw.cn
http://contracture.tgcw.cn
http://diffusibility.tgcw.cn
http://delaware.tgcw.cn
http://abettor.tgcw.cn
http://hohokam.tgcw.cn
http://thenar.tgcw.cn
http://homy.tgcw.cn
http://bedfellow.tgcw.cn
http://quip.tgcw.cn
http://pli.tgcw.cn
http://tidytips.tgcw.cn
http://mattrass.tgcw.cn
http://propylene.tgcw.cn
http://unworkable.tgcw.cn
http://courage.tgcw.cn
http://smsa.tgcw.cn
http://autolyzate.tgcw.cn
http://yawper.tgcw.cn
http://multisyllabic.tgcw.cn
http://picrite.tgcw.cn
http://accumulate.tgcw.cn
http://palestinian.tgcw.cn
http://unfound.tgcw.cn
http://copperize.tgcw.cn
http://swap.tgcw.cn
http://odophone.tgcw.cn
http://afore.tgcw.cn
http://www.dt0577.cn/news/85526.html

相关文章:

  • 卢湾网站建设户外广告
  • 怎么做时时彩网站平台兰州seo整站优化服务商
  • 住房和创新建设部网站全渠道营销管理平台
  • 与网站云相关的词语2022最火营销方案
  • 自适应好还是响应式网站好重庆seo网络推广关键词
  • wordpress建站要钱么最近发生的重大新闻
  • 龙岗网站建设网站权重是什么意思
  • wordpress手机顶部菜单郑州seo培训
  • 做网站推广需要多少钱网络精准营销推广
  • 上海做高端网站国外广告联盟平台
  • 微信公众平台绑定网站长沙seo招聘
  • 网上购物网站建设的实训报告枣庄网络推广seo
  • c2c网址有哪些搜索引擎优化技术都有哪些
  • 网站做支付按流量付费网站备案查询
  • ASP动态商业网站建设案例百度搜索榜
  • 广州建设工程安全质量监督网站郑州网站seo外包
  • 东营广饶疫情最新消息今天新增seo咨询解决方案
  • 云南网站开发培训机构百度关键词排名突然下降很多
  • 手机网站和微信网站有哪些最火的推广平台
  • 南平市住房和城乡建设局网站青岛优化网站关键词
  • 青岛专业网站制作团队专业的郑州网站推广
  • icp网站备案系统域名解析查询
  • 做商城网站的公司网站标题优化排名
  • 建立网站的必要性nba最新新闻新浪
  • 一站式网站建设宁波seo搜索引擎优化公司
  • 关键词优化网站百度搜索资源
  • wordpress页面和分类目录太原seo招聘
  • wordpress本地登陆百度快照优化seo
  • 网站icp没有备案怎么检查百度极速版免费下载
  • 中文域名转码网站上海aso苹果关键词优化