Skip to content

Commit

Permalink
修改了部分文档
Browse files Browse the repository at this point in the history
  • Loading branch information
jackfrued committed May 12, 2021
1 parent d2c6ce9 commit b67ed79
Show file tree
Hide file tree
Showing 6 changed files with 247 additions and 36 deletions.
97 changes: 97 additions & 0 deletions Day21-30/code/垃圾分类查询/index-2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>垃圾分类查询助手</title>
<style>
.search, .result {
width: 720px;
margin: 50px auto;
}
.search > input {
width: 520px;
border: none;
outline: none;
text-align: center;
font-size: 36px;
line-height: 36px;
border-bottom: 1px solid gray;
margin: 0 20px;
}
.search button {
background-color: red;
color: white;
font-size: 28px;
border: none;
outline: none;
width: 120px;
}
.result > p, .result > div {
width: 640px;
margin: 0 auto;
}
.result > p, .result span {
text-align: left;
font-size: 28px;
}
.result img {
vertical-align: middle;
}
.explain {
font-size: 12px;
color: darkgray;
}
.result .pre {
font-size: 16px;
}
</style>
</head>
<body>
<div id="app">
<div class="search">
<input type="text" placeholder="请输入垃圾名字" v-model.trim="word" @keydown.enter="search()">
<button @click="search()">查询</button>
</div>
<div class="result">
<p v-if="searched && !results">没有对应的查询结果</p>
<div v-for="result in results">
<p>
<img :src="'images/' + pictures[result.type]" width="56" :alt="types[result.type]">
&nbsp;&nbsp;
<span>{{ result.name }}</span>
&nbsp;&nbsp;
<span class="pre" v-if="result.aipre == 1">(预测结果)</span>
</p>
<p class="explain">说明:{{ result.explain }}</p>
</div>
</div>
</div>
<script src="https://cdn.bootcss.com/vue/2.6.10/vue.min.js"></script>
<script>
new Vue({
el: '#app',
data: {
word: '',
searched: false,
types: ['可回收物', '有害垃圾', '厨余垃圾', '其他垃圾'],
pictures: ['recyclable.png', 'harmful-waste.png', 'kitchen-waste.png', 'other-waste.png'],
results: []
},
methods: {
search() {
if (this.word.trim().length > 0) {
let key = 'e8c5524dd2a365f20908ced735f8e480'
let url = `http://api.tianapi.com/txapi/lajifenlei/?key=${key}&word=${this.word}`
fetch(url)
.then(resp => resp.json())
.then(json => {
this.searched = true
this.results = json.newslist
})
}
}
}
})
</script>
</body>
</html>
1 change: 0 additions & 1 deletion Day41-55/46.日志和调试工具栏.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,3 @@ queryset = Teacher.objects.values('subject__name').annotate(good=Avg('good_count
```
可见,Django的ORM框架允许我们用面向对象的方式完成关系数据库中的分组和聚合查询。
1 change: 0 additions & 1 deletion Day41-55/48.前后端分离开发入门.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,3 @@ class SubjectMapper(ModelMapper):
前后端分离的开发需要将前端页面作为静态资源进行部署,项目实际上线的时候,我们会对整个Web应用进行动静分离,静态资源通过Nginx或Apache服务器进行部署,生成动态内容的Python程序部署在uWSGI或者Gunicorn服务器上,对动态内容的请求由Nginx或Apache路由到uWSGI或Gunicorn服务器上。

在开发阶段,我们通常会使用Django自带的测试服务器,如果要尝试前后端分离,可以先将静态页面放在之前创建的放静态资源的目录下,具体的做法可以参考[项目完整代码](https://gitee.com/jackfrued/django19062)

4 changes: 2 additions & 2 deletions Day66-70/67.NumPy的应用.md
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ plt.imshow(guido_image[30:350, 90:300])

#### 统计方法

`ndarray`对象的统计方法主要包括:`sum``mean``std``var``min``max``argmin``argmax``cumsum`等,分别用于对数组中的元素求和、求平均、求标准差、求方差、找最大、找最小、求累积和等,请参考下面的代码。
`ndarray`对象的统计方法主要包括:`sum()`、`mean()`、`std()`、`var()`、`min()`、`max()`、`argmin()`、`argmax()`、`cumsum()`等,分别用于对数组中的元素求和、求平均、求标准差、求方差、找最大、找最小、求累积和等,请参考下面的代码。
```Python
array28 = np.array([1, 2, 3, 4, 5, 5, 4, 3, 2, 1])
Expand Down Expand Up @@ -920,7 +920,7 @@ print(array28.cumsum())
> **说明**:可以看出,二维数组的点积就是矩阵乘法运算。
4. `dump()`方法:保存数组到文件中,可以通过NumPy中的`load`函数从保存的文件中加载数据创建数组。
4. `dump()`方法:保存数组到文件中,可以通过NumPy中的`load()`函数从保存的文件中加载数据创建数组。
代码:
Expand Down
Loading

0 comments on commit b67ed79

Please sign in to comment.