成都车辆限行
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>成都车辆限行查询</title>
<link rel="stylesheet" type="text/css" href="css/judgeCar.css"/>
</head>
<body>
<div id="search">
<input type="text" name="" id="carNum" value="" placeholder="输入车牌号码"/>
<input type="button" name="查询" value="查询" onclick="showRe()" />
<input type="button" name="清除" value="清除记录" onclick="clearRecord()" />
</div>
<hr>
<p id="result"></p>
<script type="text/javascript">
function showRe(){
var input = document.getElementById("carNum")
var p = document.getElementById("result")
var carNo = input.value
var re = /^川[A-Z]\s*[A-Z0-9]{5}$/
var a = p.innerHTML
if (re.test(carNo)){
var digit = judgeCarNum(carNo)
if (digit){
var day = new Date().getDay()
if(digit % 5 == day || digit % 5 == day - 5){
message = carNo + "今日限行<br/>"
p.innerHTML = message + a
// p.innerHTML += carNo + "今日限行<br/>"
}else{
message2 = carNo + "今日不限行<br/>"
p.innerHTML = message2 + a
// p.innerHTML += carNo + "今日不限行<br/>"
}
}else{
p.innerHTML = carNo + "车牌号码不正确<br/>" + a
}
}else{
p.innerHTML = carNo + "车牌号码错误或不是本地车牌<br/>" + a
}
input.value =""
}
function judgeCarNum(str){
for (var index = str.length - 1; index >= 0; index -=1){
var digitStr = str[index]
if (digitStr == parseInt(digitStr)){
return parseInt(digitStr)
}
}
return null
}
function clearRecord(){
var p = document.getElementById("result")
p.innerHTML = ""
}
</script>
</body>
</html>
样式表
/* 查询div */
#search{
width: 800px;
margin: 0 auto;
margin-top: 200px;
text-align: center;
}
/* 搜索输入框 */
#carNum{
display: inline-block;
width: 520px;
height: 36px;
font-size: 32px;
line-height: 36px;
text-align: center;
vertical-align: middle;
border: none;
outline: none;
border-bottom: 1px solid dimgrey;
}
/* 查询按钮 */
#search [name = 查询]{
width: 80px;
height: 36px;
font: 28px/36px arial; /*相当于line-height: 36px*/
border: none;
color: black;
background-color: white;
/* line-height: 36px; */
vertical-align: middle;
}
/* 清除按钮 */
#search [name = 清除]{
width: 160px;
height: 36px;
font: 28px/36px arial; /*相当于line-height: 36px*/
border: none;
color: black;
background-color: white;
/* line-height: 36px; */
vertical-align: middle;
}
/* 显示标签 */
#result {
width: 640px;
margin: 0 auto;
text-align: center;
font: 32px/36px arial;
}
判断闰年
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>判断闰年</title>
<style>
#judge{
width: 800px;
margin: 0 auto;
border: none;
text-align: center;
margin-top: 200px;
}
#judge #leapYear{
width: 520px;
height: 52px;
line-height: 52px;
font-size: 36px;
color: dimgray;
border: none;
outline: none;
text-align: center;
vertical-align: middle;
border-bottom: 1px solid lightgray;
}
#judge [name = 判断]{
height: 36px;
border: none;
background-color: white;
font: 34px/36px arial;
text-align: center;
vertical-align: middle;
}
#result{
font: 36px/36px arial;
widows: 520;
text-align: center;
margin: 0 auto;
color: burlywood;
}
</style>
</head>
<body>
<div id="judge">
<input type="text" name="输入" id="leapYear" value="" placeholder="请输入年份"/>
<input type="button" name="判断" id="" value="判断" onclick="judgeYear()"/>
</div>
<hr>
<p id="result"></p>
<script type="text/javascript">
judgeYear = function(){
var input = document.getElementById("leapYear")
var year = input.value
show = document.getElementById("result")
console.log(yearInt)
var content = show.innerHTML
if(year == parseInt(year) && (parseInt(year) > 0)){
var yearInt = parseInt(year)
if (yearInt % 400 == 0 || yearInt % 4 == 0 && yearInt %100 != 0){
show.innerHTML = "第" + year + "年" + "是闰年<br/>" + content
}else{
show.innerHTML = "第" + year + "年" + "不是闰年<br/>" + content
}
}else{
show.innerHTML = "输入的内容" + year + "不符合要求<br/>" + content
}
}
</script>
</body>
</html>
python之禅
<!--
Beautiful is better than ugly. 格式优美的代码比丑陋的好
Explicit is better than implicit.清晰明了的代码好于晦涩难懂的代码
Simple is better than complex.简单的代码好于复杂的代码
Complex is better than complicated.复杂的代码好于繁杂的代码
Flat is better than nested.扁平的代码好于嵌套的代码
Sparse is better than dense.稀疏有间隔的代码好于紧凑浓密的代码
Readability counts.代码的可读性是很重要
Special cases aren't special enough to break the rules.
Although practicality beats purity.尽管有一些特殊情况会让代码更加实现也尽量不要打破这些规则
Errors should never pass silently.
Unless explicitly silenced.错误应该避免,除非你需要错误
In the face of ambiguity, refuse the temptation to guess.当存在多种可能,不要尝试去猜测,不要去写拥有不确定可能的代码
There should be one-- and preferably only one --obvious way to do it.而是尽量找一种,最好是唯一一种明显的解决方案(如果不确定,就用穷举法)
Although that way may not be obvious at first unless you're Dutch.虽然这并不容易,因为你不是 Python 之父(这里的Dutch是指Guido)
Now is better than never.
Although never is often better than *right* now.做也许好过不做,但不假思索就动手还不如不做(动手之前要细思量)
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.如果你无法向人描述你的方案,那肯定不是一个好方案;反之亦然(方案测评标准)
Namespaces are one honking great idea -- let's do more of those!命名空间是一种绝妙的理念,我们应当多加利用(倡导与号召)
-->