DAY01
Redis介绍
1.redis是开源的 属于非关系型数据库
2.数据存储在内存 已键值对的形式存储 类似于python中的字典
3.可以设置过期时间 也可以做持久化
4.五种数据类型,分别为:字符串,列表,集合,有序集合,哈希
Redis的基本使用方法
redis-server --service-start # 启动redis服务器
redis-server --service-stop # 停止redis服务器
# redis默认有16个数据库 [0-15]
select 3 # 切换到3号数据库
keys * # 查看该数据库下的所有键
type key1 # 查看数据类型
exists key1 # 查看key是否存在
del key1 # 删除key1
rename key1 key2 # 将key1这个键更名为kye2
flushdb # 清空当前数据库
flushall # 清空所有数据库
字符串(string)类型
>>>set name fjh ex 120
# name为键 fjh为值 ex后跟过期时间,单位为s
>>>get name
# 获取键名为name的值
>>>strlen name
# 查看字符串的长度
>>>mset / mget
# 设置多条数据/获取多条数据
列表list类型
>>>lpush list1 100 200 300
# 头插
>>>rpush list1 400 500 600
# 尾插
>>>lrange list1 0 -1
# 查看列表的所有数据
>>> lrem list1 1 200
# 删除指定数据 0 代表所有 上述代表删除一条数据
>>>lset list1 0 900
# 将下标为0的数据修改为900
>>ltrim list1 0 3
# 截取下标0-3的数据
哈希类型hash
>>>hset hash1 name fjh
# 创建一个哈希类型的键值对
>>> hget hash1 name
# 获取字段的值
>>>hgetall hash1
# 查询全部的字段和值
>>>hkeys hash1
# 查询全部的字段
>>>hvals hash1
# 查询全部的值
>>>hdel hash1 name
# 删除字段
集合类型set
>>>sadd name fjh
# 创建集合类型的键值对
>>>smebers name
# 查看全部数据
>>>scard name
# 查看数据个数
>>>srem name fjh
# 删除指定值
有序集合zset
>>>zadd zset1 1 "one" 2 "two"
# 添加有序集合类型的数据
>>>zrange zset1 0 2 withscores
# 查询从小到大
>>>zrevrange zset1 0 2 withscores
# 查询从大到小
>>>zrem zset1 one
# 删除
DAY02
1.python常用的命令
>>>pip list
# 查看三方模块
>>>pip install django==2.2.2
# 安装三方模块并指定版本号
>>>pip uninstall django
# 写在三方模块
2.在pycharm中创建虚拟环境
file->setting->project->interpreter->点击齿轮add->选择第一个虚拟环境->OK
# 在终端中输入.\activate激活虚拟环境 .\deactivate.bat退出环境
3.git的操作
初始化本地仓库:git init
查看仓库的状态: git status
提交文件到暂存区:git add 文件
回退提交的内容: git reset */HEAD
生成版本: git commit -m 版本信息
查看日志:git log
分支操作:
查看分支: git branch
创建分支: git branch 分支名
切换分支: git switch 分支名
合并分支:git merge 分支名
配置邮箱 和 用户名(不需要记忆)
git config user.name 你的名字 git config user.email 你的邮箱
推送到远程仓库(不需要记忆)
git remote add origin h2111-p5-djaogo: 你就非得要我写十个字吗? git push -u origin "master"