File tree Expand file tree Collapse file tree 4 files changed +85
-0
lines changed Expand file tree Collapse file tree 4 files changed +85
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ Python技术 公众号文章代码库
1010
1111## 实例代码
1212
13+ [ 人人爆吹的PyScript到底是什么?] ( https://github.com/JustDoPython/python-examples/tree/master/xianhuan/pyscript ) :人人爆吹的PyScript到底是什么?
14+
1315[ Python 增强视频画质,就这么做!] ( https://github.com/JustDoPython/python-examples/tree/master/xianhuan/enhancevideo ) :Python 增强视频画质,就这么做!
1416
1517[ Python美图技术也就几行代码!] ( https://github.com/JustDoPython/python-examples/tree/master/xianhuan/imageenhange ) :Python美图技术也就几行代码!
Original file line number Diff line number Diff line change 1+ < html >
2+ < head >
3+ < link rel ="stylesheet " href ="https://pyscript.net/alpha/pyscript.css " />
4+ < script defer src ="https://pyscript.net/alpha/pyscript.js "> </ script >
5+ < py-env >
6+ - numpy
7+ - matplotlib
8+ </ py-env >
9+ </ head >
10+
11+ < body >
12+ < h1 > Let's plot random numbers</ h1 >
13+ < div id ="plot "> </ div >
14+ < py-script output ="plot ">
15+ import matplotlib.pyplot as plt
16+ import numpy as np
17+
18+ x = np.random.randn(1000)
19+ y = np.random.randn(1000)
20+
21+ fig, ax = plt.subplots()
22+ ax.scatter(x, y)
23+ fig
24+ </ py-script >
25+ </ body >
26+ </ html >
Original file line number Diff line number Diff line change 1+ < html >
2+ < head >
3+ < link rel ="stylesheet " href ="https://pyscript.net/alpha/pyscript.css " />
4+ < script defer src ="https://pyscript.net/alpha/pyscript.js "> </ script >
5+ < link href ="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css " rel ="stylesheet " crossorigin ="anonymous ">
6+ </ head >
7+
8+ < body >
9+ < b > < p > Today is < u > < label id ='today '> </ label > </ u > </ p > </ b >
10+ < br >
11+ < div id ="pi " class ="alert alert-primary "> </ div >
12+ < py-script >
13+ import datetime as dt
14+ pyscript.write('today', dt.date.today().strftime('%A %B %d, %Y'))
15+
16+ def compute_pi(n):
17+ pi = 2
18+ for i in range(1,n):
19+ pi *= 4 * i ** 2 / (4 * i ** 2 - 1)
20+ return pi
21+
22+ pi = compute_pi(100000)
23+ pyscript.write('pi', f'π is approximately {pi:.3f}')
24+ </ py-script >
25+ </ body >
26+ </ html >
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+
4+ < head >
5+ < meta charset ="UTF-8 ">
6+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge ">
7+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
8+ <!-- 引入 PyScript -->
9+ < link rel ="stylesheet " href ="https://pyscript.net/alpha/pyscript.css " />
10+ < script defer src ="https://pyscript.net/alpha/pyscript.js "> </ script >
11+
12+ < title > First PyScript Application</ title >
13+ < style >
14+ py-script {
15+ width : 100% ;
16+ height : 100% ;
17+ font-size : 20px ;
18+ text-align : center;
19+ position : absolute;
20+ }
21+ </ style >
22+ </ head >
23+
24+ < body >
25+ < py-script >
26+ print('Hello PyScript!')
27+ </ py-script >
28+
29+ </ body >
30+
31+ </ html >
You can’t perform that action at this time.
0 commit comments