会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132464个问题
Python 全系列/第八阶段:Vue框架/vue框架 20656楼
Python 全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 20657楼

from flask import Flask, url_for
from werkzeug.routing import BaseConverter

app = Flask(__name__)


@app.route('/')
def hello_world():
    # return 'Hello World!'
    # return '/list/'
    # return url_for('list1')
    return url_for("list1", nub=88, uname="zhejiang", pwd="///")


@app.route('/list/<int:nub>')
def list1(nub):
    print("这是list页面")


class Telephonenumber(BaseConverter):
    regex = r"1[3456789]\d{9}"


app.url_map.converters["tel"] = Telephonenumber

@app.route('/telephone/<tel:nb>')
def mytelephone(nb):
    return "您输入的电话号码是:{}".format(nb)

@app.route('/list2/<modules>')
def list2(modules):
    li=modules.split("+")
    print(li)
    print(li[0])
    print(li[1])
    return "返回的值是%s"%li

class ListConveter(BaseConverter):
    def to_python(self, value):
        # return "hello"
        # return value
        return value.split("+")

    def to_url(self, value):
        return value
app.url_map.converters["li"]=ListConveter


@app.route('/list3/<li:modules>')
def list3(modules):
    return "返回的值是%s"%modules

@app.route("/hellow/")
def hellow1():
    args= url_for("list3",modules="zhejiang+beijing")
    return "返回的URL是:{}".format(args)


if __name__ == '__main__':
    app.run()

1623073878(1).png

老师,在li类中,添加了to_url方法后,为什么再执行上一个视频中的地址(/list3/enter+home)就会报错,然后注释掉li类中的to_url方法就又可以正常执行。

Python 全系列/第八阶段:轻量级Web开发利器-Flask框架/Flask视图基础和URL 20658楼

html代码:

<html>
	<head>
		<title>jQuery操作表格</title>
		<meta charset="UTF-8"/>
		<!--声明css代码域-->
		<style type="text/css">
			tr{
				height: 40px;
			}
		</style>
	 	
	 	<script type="text/javascript" src="js/jquery-1.9.1.js" ></script>
	 	<script type="text/javascript" src="js/gwc.js" ></script>
		
	</head>
	<body>
		<h3>jQuery操作表格</h3>
		<hr />
		<input type="button" id="fx" value="反选" />
		<input type="button" id="addRow" value="新增一行" />
		<input type="button" id="delRow" value="删除行" />
		<input type="button" id="copyRow" value="复制行" />
		<table border="1px" cellpadding="10px" cellspacing="0" id="ta">
			<tr>
				<td width="50px"><input type="checkbox" name="chks" id="chks" value="1" /></td>
				<td width="200px">书名</td>
				<td width="200px">作者</td>
				<td width="200px">数量</td>
				<td width="200px">操作</td>
			</tr>
			<tr id="">
				<td><input type="checkbox" name="chk" id="" value="2"/></td>
				<td>《Java编程之道》</td>
				<td>wollo</td>
				<td>10</td>
				<td>
					<input type="button" name="aa" id="" value="修改数量"  />
					<input type="button" name="" id="" value="删除" />
				</td>
			</tr>
			<tr>
				<td><input type="checkbox" name="chk" id="" value="3" /></td>
				<td>《Python和我的故事》</td>
				<td>赵老师</td>
				<td>10</td>
				<td>
					<input type="button" name="" id="" value="修改数量" />
					<input type="button" name="" id="" value="删除" />
				</td>
			</tr>
			<tr>
				<td><input type="checkbox" name="chk" id="" value="4" /></td>
				<td>《web开发详解》</td>
				<td>张老师</td>
				<td>30</td>
				<td>
					<input type="button" name="" id="" value="修改数量" />
					<input type="button" name="" id="" value="删除" />
				</td>
			</tr>			
		</table>
	</body>
</html>

jq代码:

$(function(){
	
	//确定全选和全不选操作
	$("#chks").click(function(){
		
		var flag=$(this).prop("checked")
	
		$("input[name=chk]").prop("checked",flag)
		
	})
	
	//判断是否全选的操作
	$("input[name=chk]").click(function(){
		
		var flag=true
		
		var chk=$("input[name=chk]")
		
		chk.each(function(){
			
			if(!$(this).prop("checked")){
				
				flag=false
				return
			}
		})
		
		$("#chks").prop("checked",flag)
	})
	
	
	//反选按钮的操作
	$("#fx").click(function(){
		
		var chx=$("input[type=checkbox]")
		
		chx.each(function(){
			
			
			//获得每一个框的初始状态
			var flag=$(this).prop("checked")
			
			$(this).prop("checked",!flag)
		})
	})
})

老师有几个问题 没听明白

    1. 这个this代表的是什么意思  如果是对象本身 是哪个对象   我的理解是name=chk的全部多选框 对吗

if(!$(this).prop("checked")){

    2.这个代码里边  如果chk全部都被选了  那么就不进入if里边了  flag的值就是true

    如果chk有一个没有被选择  那么就进入if语句里  flag的值为false  然后返回给最底下那行代码  对吗

	$("input[name=chk]").click(function(){
		
		var flag=true
		
		var chk=$("input[name=chk]")
		
		chk.each(function(){
			
			if(!$(this).prop("checked")){
				
				flag=false
				return
			}
		})
		
		$("#chks").prop("checked",flag)
	})

    3. 还有这个里边的this代表的是哪个对象   是属性type=checkbox的全部多选框吗

//反选按钮的操作
	$("#fx").click(function(){
		
		var chx=$("input[type=checkbox]")
		
		chx.each(function(){
			
			
			//获得每一个框的初始状态
			var flag=$(this).prop("checked")
			
			$(this).prop("checked",!flag)
		})
	})


Python 全系列/第七阶段:网页编程基础/jquery 20659楼
大数据全系列/第十七阶段:Spark分布式计算框架(旧))/Spark分布式计算框架之SparkStreaming 20661楼
大数据全系列/第十七阶段:Spark分布式计算框架(旧))/Spark分布式计算框架之SparkStreaming 20662楼
JAVA 全系列/第一阶段:JAVA 快速入门/面向对象详解和JVM底层内存分析 20664楼
JAVA 全系列/第三十阶段:面试和成功求职的秘技/笔试和面试 20666楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/容器(旧) 20668楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/容器(旧) 20669楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/数据结构 20670楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637