Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
csdn_franckjun
Python-100-Days
提交
daccf3fe
P
Python-100-Days
项目概览
csdn_franckjun
/
Python-100-Days
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Python-100-Days
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
daccf3fe
编写于
12月 30, 2019
作者:
J
jackfrued
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更新了部分文档
上级
eb2cb5f0
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
43 addition
and
39 deletion
+43
-39
Day01-15/01.初识Python.md
Day01-15/01.初识Python.md
+4
-4
Day36-40/36-38.关系型数据库MySQL.md
Day36-40/36-38.关系型数据库MySQL.md
+6
-6
Day36-40/39-40.NoSQL入门.md
Day36-40/39-40.NoSQL入门.md
+4
-4
Day36-40/code/contact/main.py
Day36-40/code/contact/main.py
+2
-2
Day41-55/42.深入模型.md
Day41-55/42.深入模型.md
+3
-3
Day41-55/code/shop/shop/settings.py
Day41-55/code/shop/shop/settings.py
+2
-2
Day41-55/code/shop_origin/shop/settings.py
Day41-55/code/shop_origin/shop/settings.py
+2
-2
Day61-65/code/hello-tornado/example04.py
Day61-65/code/hello-tornado/example04.py
+3
-1
Day61-65/code/hello-tornado/example05.py
Day61-65/code/hello-tornado/example05.py
+3
-1
Day61-65/code/hello-tornado/example06.py
Day61-65/code/hello-tornado/example06.py
+3
-3
Day61-65/code/hello-tornado/example07.py
Day61-65/code/hello-tornado/example07.py
+3
-3
Day61-65/code/project_of_tornado/backend_server.py
Day61-65/code/project_of_tornado/backend_server.py
+3
-3
Day91-100/95.使用Django开发商业项目.md
Day91-100/95.使用Django开发商业项目.md
+5
-5
未找到文件。
Day01-15/01.初识Python.md
浏览文件 @
daccf3fe
...
@@ -57,15 +57,15 @@ yum -y install wget gcc zlib-devel bzip2-devel openssl-devel ncurses-devel sqlit
...
@@ -57,15 +57,15 @@ yum -y install wget gcc zlib-devel bzip2-devel openssl-devel ncurses-devel sqlit
2.
下载Python源代码并解压缩到指定目录。
2.
下载Python源代码并解压缩到指定目录。
```
Shell
```
Shell
wget https://www.python.org/ftp/python/3.7.
3/Python-3.7.3.tg
z
wget https://www.python.org/ftp/python/3.7.
6/Python-3.7.6.tar.x
z
xz -d Python-3.7.
3
.tar.xz
xz -d Python-3.7.
6
.tar.xz
tar -xvf Python-3.7.
3
.tar
tar -xvf Python-3.7.
6
.tar
```
```
3.
切换至Python源代码目录并执行下面的命令进行配置和安装。
3.
切换至Python源代码目录并执行下面的命令进行配置和安装。
```
Shell
```
Shell
cd Python-3.7.
3
cd Python-3.7.
6
./configure --prefix=/usr/local/python37 --enable-optimizations
./configure --prefix=/usr/local/python37 --enable-optimizations
make && make install
make && make install
```
```
...
...
Day36-40/36-38.关系型数据库MySQL.md
浏览文件 @
daccf3fe
...
@@ -174,7 +174,7 @@ MySQL在过去由于性能高、成本低、可靠性好,已经成为最流行
...
@@ -174,7 +174,7 @@ MySQL在过去由于性能高、成本低、可靠性好,已经成为最流行
alter user 'root'@'localhost' identified by '123456';
alter user 'root'@'localhost' identified by '123456';
```
```
>
说明
:MySQL较新的版本默认不允许使用弱口令作为用户口令,所以我们通过上面的前两条命令修改了验证用户口令的策略和口令的长度。事实上我们不应该使用弱口令,因为存在用户口令被暴力破解的风险。近年来,攻击数据库窃取数据和劫持数据库勒索比特币的事件屡见不鲜,要避免这些潜在的风险,最为重要的一点是不要让数据库服务器暴露在公网上(最好的做法是将数据库置于内网,至少要做到不向公网开放数据库服务器的访问端口),另外要保管好`root`账号的口令,应用系统需要访问数据库时,通常不使用`root`账号进行访问,而是创建其他拥有适当权限的账号来访问。
>
**说明**
:MySQL较新的版本默认不允许使用弱口令作为用户口令,所以我们通过上面的前两条命令修改了验证用户口令的策略和口令的长度。事实上我们不应该使用弱口令,因为存在用户口令被暴力破解的风险。近年来,攻击数据库窃取数据和劫持数据库勒索比特币的事件屡见不鲜,要避免这些潜在的风险,最为重要的一点是不要让数据库服务器暴露在公网上(最好的做法是将数据库置于内网,至少要做到不向公网开放数据库服务器的访问端口),另外要保管好`root`账号的口令,应用系统需要访问数据库时,通常不使用`root`账号进行访问,而是创建其他拥有适当权限的账号来访问。
再次使用客户端工具连接MySQL服务器时,就可以使用新设置的口令了。在实际开发中,为了方便用户操作,可以选择图形化的客户端工具来连接MySQL服务器,包括:
再次使用客户端工具连接MySQL服务器时,就可以使用新设置的口令了。在实际开发中,为了方便用户操作,可以选择图形化的客户端工具来连接MySQL服务器,包括:
...
@@ -1199,7 +1199,7 @@ insert into tb_emp values
...
@@ -1199,7 +1199,7 @@ insert into tb_emp values
# 1. 创建数据库连接对象
# 1. 创建数据库连接对象
con = pymysql.connect(host='localhost', port=3306,
con = pymysql.connect(host='localhost', port=3306,
database='hrs', charset='utf8',
database='hrs', charset='utf8',
user='
root', password='123456
')
user='
yourname', password='yourpass
')
try:
try:
# 2. 通过连接对象获取游标
# 2. 通过连接对象获取游标
with con.cursor() as cursor:
with con.cursor() as cursor:
...
@@ -1231,7 +1231,7 @@ insert into tb_emp values
...
@@ -1231,7 +1231,7 @@ insert into tb_emp values
no = int(input('编号: '))
no = int(input('编号: '))
con = pymysql.connect(host='localhost', port=3306,
con = pymysql.connect(host='localhost', port=3306,
database='hrs', charset='utf8',
database='hrs', charset='utf8',
user='
root', password='123456
',
user='
yourname', password='yourpass
',
autocommit=True)
autocommit=True)
try:
try:
with con.cursor() as cursor:
with con.cursor() as cursor:
...
@@ -1263,7 +1263,7 @@ insert into tb_emp values
...
@@ -1263,7 +1263,7 @@ insert into tb_emp values
loc = input('所在地: ')
loc = input('所在地: ')
con = pymysql.connect(host='localhost', port=3306,
con = pymysql.connect(host='localhost', port=3306,
database='hrs', charset='utf8',
database='hrs', charset='utf8',
user='
root', password='123456
',
user='
yourname', password='yourpass
',
autocommit=True)
autocommit=True)
try:
try:
with con.cursor() as cursor:
with con.cursor() as cursor:
...
@@ -1291,7 +1291,7 @@ insert into tb_emp values
...
@@ -1291,7 +1291,7 @@ insert into tb_emp values
def main():
def main():
con = pymysql.connect(host='localhost', port=3306,
con = pymysql.connect(host='localhost', port=3306,
database='hrs', charset='utf8',
database='hrs', charset='utf8',
user='
root', password='123456
')
user='
yourname', password='yourpass
')
try:
try:
with con.cursor(cursor=DictCursor) as cursor:
with con.cursor(cursor=DictCursor) as cursor:
cursor.execute('select dno as no, dname as name, dloc as loc from tb_dept')
cursor.execute('select dno as no, dname as name, dloc as loc from tb_dept')
...
@@ -1334,7 +1334,7 @@ insert into tb_emp values
...
@@ -1334,7 +1334,7 @@ insert into tb_emp values
size = int(input('大小: '))
size = int(input('大小: '))
con = pymysql.connect(host='localhost', port=3306,
con = pymysql.connect(host='localhost', port=3306,
database='hrs', charset='utf8',
database='hrs', charset='utf8',
user='
root', password='123456
')
user='
yourname', password='yourpass
')
try:
try:
with con.cursor() as cursor:
with con.cursor() as cursor:
cursor.execute(
cursor.execute(
...
...
Day36-40/39-40.NoSQL入门.md
浏览文件 @
daccf3fe
...
@@ -107,7 +107,7 @@ redis-server
...
@@ -107,7 +107,7 @@ redis-server
方式一:通过参数指定认证口令和AOF持久化方式。
方式一:通过参数指定认证口令和AOF持久化方式。
```
Shell
```
Shell
redis-server --requirepass
1qaz2wsx
--appendonly yes
redis-server --requirepass
yourpass
--appendonly yes
```
```
方式二:通过指定的配置文件来修改Redis的配置。
方式二:通过指定的配置文件来修改Redis的配置。
...
@@ -119,7 +119,7 @@ redis-server /root/redis-5.0.4/redis.conf
...
@@ -119,7 +119,7 @@ redis-server /root/redis-5.0.4/redis.conf
下面我们使用第一种方式来启动Redis并将其置于后台运行,将Redis产生的输出重定向到名为redis.log的文件中。
下面我们使用第一种方式来启动Redis并将其置于后台运行,将Redis产生的输出重定向到名为redis.log的文件中。
```
Shell
```
Shell
redis-server --requirepass
1qaz2wsx
> redis.log &
redis-server --requirepass
yourpass
> redis.log &
```
```
可以通过ps或者netstat来检查Redis服务器是否启动成功。
可以通过ps或者netstat来检查Redis服务器是否启动成功。
...
@@ -133,7 +133,7 @@ netstat -nap | grep redis-server
...
@@ -133,7 +133,7 @@ netstat -nap | grep redis-server
```
Shell
```
Shell
redis-cli
redis-cli
127.0.0.1:6379> auth
1qaz2wsx
127.0.0.1:6379> auth
yourpass
OK
OK
127.0.0.1:6379> ping
127.0.0.1:6379> ping
PONG
PONG
...
@@ -274,7 +274,7 @@ python3
...
@@ -274,7 +274,7 @@ python3
```
Python
```
Python
>>> import redis
>>> import redis
>>> client = redis.Redis(host='1.2.3.4', port=6379, password='
1qaz2wsx
')
>>> client = redis.Redis(host='1.2.3.4', port=6379, password='
yourpass
')
>>> client.set('username', 'admin')
>>> client.set('username', 'admin')
True
True
>>> client.hset('student', 'name', 'hao')
>>> client.hset('student', 'name', 'hao')
...
...
Day36-40/code/contact/main.py
浏览文件 @
daccf3fe
...
@@ -171,8 +171,8 @@ def find_contacters(con):
...
@@ -171,8 +171,8 @@ def find_contacters(con):
def
main
():
def
main
():
con
=
pymysql
.
connect
(
host
=
'1
20.77.222.217
'
,
port
=
3306
,
con
=
pymysql
.
connect
(
host
=
'1
.2.3.4
'
,
port
=
3306
,
user
=
'
root'
,
passwd
=
'123456
'
,
user
=
'
yourname'
,
passwd
=
'yourpass
'
,
db
=
'address'
,
charset
=
'utf8'
,
db
=
'address'
,
charset
=
'utf8'
,
autocommit
=
True
,
autocommit
=
True
,
cursorclass
=
pymysql
.
cursors
.
DictCursor
)
cursorclass
=
pymysql
.
cursors
.
DictCursor
)
...
...
Day41-55/42.深入模型.md
浏览文件 @
daccf3fe
...
@@ -29,10 +29,10 @@
...
@@ -29,10 +29,10 @@
'default': {
'default': {
'ENGINE': 'django.db.backends.mysql',
'ENGINE': 'django.db.backends.mysql',
'NAME': 'oa',
'NAME': 'oa',
'HOST': '1
27.0.0.1
',
'HOST': '1
.2.3.4
',
'PORT': 3306,
'PORT': 3306,
'USER': '
root
',
'USER': '
yourname
',
'PASSWORD': '
123456
',
'PASSWORD': '
yourpass
',
}
}
}
}
...
...
Day41-55/code/shop/shop/settings.py
浏览文件 @
daccf3fe
...
@@ -81,8 +81,8 @@ DATABASES = {
...
@@ -81,8 +81,8 @@ DATABASES = {
'NAME'
:
'shop'
,
'NAME'
:
'shop'
,
'HOST'
:
'localhost'
,
'HOST'
:
'localhost'
,
'PORT'
:
3306
,
'PORT'
:
3306
,
'USER'
:
'
root
'
,
'USER'
:
'
yourname
'
,
'PASSWORD'
:
'
123456
'
,
'PASSWORD'
:
'
yourpass
'
,
}
}
}
}
...
...
Day41-55/code/shop_origin/shop/settings.py
浏览文件 @
daccf3fe
...
@@ -81,8 +81,8 @@ DATABASES = {
...
@@ -81,8 +81,8 @@ DATABASES = {
'NAME'
:
'Shop'
,
'NAME'
:
'Shop'
,
'HOST'
:
'localhost'
,
'HOST'
:
'localhost'
,
'PORT'
:
3306
,
'PORT'
:
3306
,
'USER'
:
'
root
'
,
'USER'
:
'
yourname
'
,
'PASSWORD'
:
'
123456
'
,
'PASSWORD'
:
'
yourpass
'
,
}
}
}
}
...
...
Day61-65/code/hello-tornado/example04.py
浏览文件 @
daccf3fe
...
@@ -14,8 +14,10 @@ from tornado.options import define, options, parse_command_line
...
@@ -14,8 +14,10 @@ from tornado.options import define, options, parse_command_line
define
(
'port'
,
default
=
8888
,
type
=
int
)
define
(
'port'
,
default
=
8888
,
type
=
int
)
# 请求天行数据提供的API数据接口
REQ_URL
=
'http://api.tianapi.com/guonei/'
REQ_URL
=
'http://api.tianapi.com/guonei/'
API_KEY
=
'772a81a51ae5c780251b1f98ea431b84'
# 在天行数据网站注册后可以获得API_KEY
API_KEY
=
'your_personal_api_key'
class
MainHandler
(
tornado
.
web
.
RequestHandler
):
class
MainHandler
(
tornado
.
web
.
RequestHandler
):
...
...
Day61-65/code/hello-tornado/example05.py
浏览文件 @
daccf3fe
...
@@ -14,8 +14,10 @@ from tornado.options import define, options, parse_command_line
...
@@ -14,8 +14,10 @@ from tornado.options import define, options, parse_command_line
define
(
'port'
,
default
=
8888
,
type
=
int
)
define
(
'port'
,
default
=
8888
,
type
=
int
)
# 请求天行数据提供的API数据接口
REQ_URL
=
'http://api.tianapi.com/guonei/'
REQ_URL
=
'http://api.tianapi.com/guonei/'
API_KEY
=
'772a81a51ae5c780251b1f98ea431b84'
# 在天行数据网站注册后可以获得API_KEY
API_KEY
=
'your_personal_api_key'
class
MainHandler
(
tornado
.
web
.
RequestHandler
):
class
MainHandler
(
tornado
.
web
.
RequestHandler
):
...
...
Day61-65/code/hello-tornado/example06.py
浏览文件 @
daccf3fe
...
@@ -15,13 +15,13 @@ define('port', default=8888, type=int)
...
@@ -15,13 +15,13 @@ define('port', default=8888, type=int)
async
def
connect_mysql
():
async
def
connect_mysql
():
return
await
aiomysql
.
connect
(
return
await
aiomysql
.
connect
(
host
=
'1
20.77.222.217
'
,
host
=
'1
.2.3.4
'
,
port
=
3306
,
port
=
3306
,
db
=
'hrs'
,
db
=
'hrs'
,
charset
=
'utf8'
,
charset
=
'utf8'
,
use_unicode
=
True
,
use_unicode
=
True
,
user
=
'
root
'
,
user
=
'
yourname
'
,
password
=
'
123456
'
,
password
=
'
yourpass
'
,
)
)
...
...
Day61-65/code/hello-tornado/example07.py
浏览文件 @
daccf3fe
...
@@ -21,13 +21,13 @@ define('port', default=8888, type=int)
...
@@ -21,13 +21,13 @@ define('port', default=8888, type=int)
def
get_mysql_connection
():
def
get_mysql_connection
():
return
connect
(
return
connect
(
host
=
'1
20.77.222.217
'
,
host
=
'1
.2.3.4
'
,
port
=
3306
,
port
=
3306
,
db
=
'hrs'
,
db
=
'hrs'
,
charset
=
'utf8'
,
charset
=
'utf8'
,
use_unicode
=
True
,
use_unicode
=
True
,
user
=
'
root
'
,
user
=
'
yourname
'
,
password
=
'
123456
'
,
password
=
'
yourpass
'
,
)
)
...
...
Day61-65/code/project_of_tornado/backend_server.py
浏览文件 @
daccf3fe
...
@@ -19,13 +19,13 @@ from service.handlers.handlers_for_charts import ChartHandler
...
@@ -19,13 +19,13 @@ from service.handlers.handlers_for_charts import ChartHandler
async
def
connect_mysql
():
async
def
connect_mysql
():
return
await
aiomysql
.
connect
(
return
await
aiomysql
.
connect
(
host
=
'1
20.77.222.217
'
,
host
=
'1
.2.3.4
'
,
port
=
3306
,
port
=
3306
,
db
=
'hrs'
,
db
=
'hrs'
,
charset
=
'utf8'
,
charset
=
'utf8'
,
use_unicode
=
True
,
use_unicode
=
True
,
user
=
'
root
'
,
user
=
'
yourname
'
,
password
=
'
123456
'
,
password
=
'
yourpass
'
,
)
)
...
...
Day91-100/95.使用Django开发商业项目.md
浏览文件 @
daccf3fe
...
@@ -853,7 +853,7 @@ CACHES = {
...
@@ -853,7 +853,7 @@ CACHES = {
'CONNECTION_POOL_KWARGS': {
'CONNECTION_POOL_KWARGS': {
'max_connections': 1000,
'max_connections': 1000,
},
},
'PASSWORD': '
1qaz2wsx
',
'PASSWORD': '
yourpass
',
}
}
},
},
# 页面缓存
# 页面缓存
...
@@ -868,7 +868,7 @@ CACHES = {
...
@@ -868,7 +868,7 @@ CACHES = {
'CONNECTION_POOL_KWARGS': {
'CONNECTION_POOL_KWARGS': {
'max_connections': 500,
'max_connections': 500,
},
},
'PASSWORD': '
1qaz2wsx
',
'PASSWORD': '
yourpass
',
}
}
},
},
# 会话缓存
# 会话缓存
...
@@ -884,7 +884,7 @@ CACHES = {
...
@@ -884,7 +884,7 @@ CACHES = {
'CONNECTION_POOL_KWARGS': {
'CONNECTION_POOL_KWARGS': {
'max_connections': 2000,
'max_connections': 2000,
},
},
'PASSWORD': '
1qaz2wsx
',
'PASSWORD': '
yourpass
',
}
}
},
},
# 接口数据缓存
# 接口数据缓存
...
@@ -899,7 +899,7 @@ CACHES = {
...
@@ -899,7 +899,7 @@ CACHES = {
'CONNECTION_POOL_KWARGS': {
'CONNECTION_POOL_KWARGS': {
'max_connections': 500,
'max_connections': 500,
},
},
'PASSWORD': '
1qaz2wsx
',
'PASSWORD': '
yourpass
',
}
}
},
},
}
}
...
@@ -1781,7 +1781,7 @@ CORS_ORIGIN_ALLOW_ALL = True
...
@@ -1781,7 +1781,7 @@ CORS_ORIGIN_ALLOW_ALL = True
>>> signer.unsign(value)
>>> signer.unsign(value)
'hello, world!'
'hello, world!'
>>>
>>>
>>> signer = Signer(salt='
1qaz2wsx
')
>>> signer = Signer(salt='
yoursalt
')
>>> signer.sign('hello, world!')
>>> signer.sign('hello, world!')
'hello, world!:9vEvG6EA05hjMDB5MtUr33nRA_M'
'hello, world!:9vEvG6EA05hjMDB5MtUr33nRA_M'
>>>
>>>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录