46 lines
1.0 KiB
HTML
46 lines
1.0 KiB
HTML
<!doctype html>
|
|
<html>
|
|
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>姓名代码查询</title>
|
|
<style>
|
|
#a{
|
|
align-self: center;
|
|
}
|
|
#ans{
|
|
text-align: center;
|
|
}
|
|
</style>
|
|
<script type="text/javascript" src="brython.js"></script>
|
|
<script type="text/javascript" src="brython_stdlib.js"></script>
|
|
</head>
|
|
|
|
<body onload="brython(1)">
|
|
<h1>输入姓名(一行),点击“确认”显示代码。</h1>
|
|
<div id="a">
|
|
<input id="name"></input>
|
|
<button id="check">确认</button></div>
|
|
<div>
|
|
<label id="ans"></label>
|
|
</div>
|
|
<script type="text/python">
|
|
from browser import document
|
|
from pickle import load
|
|
with open("File.data","rb") as f:
|
|
d=load(f)
|
|
def run(data):
|
|
t=document["name"].value
|
|
ans=""
|
|
for i in range(len(t)):
|
|
try:
|
|
ans += d[t[i]]+" "
|
|
except KeyError:
|
|
document.alert("Can't convert '%s'."%(t[i]))
|
|
document["ans"].text=ans
|
|
document["check"].bind("click",run)
|
|
|
|
</script>
|
|
</body>
|
|
|
|
</html> |