聊天机器人
课程资源
requests库
#发送get请求
response = r.get(url)
#发送post请求
response = r.post(url)
#req对象的相关属性
import requests
url = 'https://www.baidu.com'
req = requests.get(url)
print(req.status_code)
# 响应状态码
print(req.text)
# 响应的文本内容
print(req.content)
# 响应的二进制内容
print(req.cookies)
# 响应的cookies
print(req.encoding)
# 响应的编码
print(req.headers)
# 响应的头部信息
print(req.url)
# 响应的网址
print(req.history)
# 响应的历史
Pyinstaller模块
pyinstaller [参数] 文件名.py
常用命令
- -F, –onefile 打包一个单个文件,如果你的代码都写在一个. py 文件的话,可以用这个,如果是多个. py 文件就别用
- -D, –onedir 打包多个文件,在 dist 中生成很多依赖文件,适合以框架形式编写工具代码,我个人比较推荐这样,代码易于维护
- -K, –tk 在部署时包含 TCL/TK
- -a, –ascii 不包含编码. 在支持 Unicode 的 python 版本上默认包含所有的编码.
- -d, –debug 产生 debug 版本的可执行文件
- -w,–windowed,–noconsole 使用 Windows 子系统执行. 当程序启动的时候不会打开命令行 (只对 Windows 有效)
- -c,–nowindowed,–console 使用控制台子系统执行 (默认)(只对 Windows 有效)
#打包单个文件,并隐藏控制台
pyinstaller -F -w test.py
#打包单个文件,默认以控制台显示
pyinstaller -F test.py
#打包单个文件,以控制台显示
pyinstaller -F -c test.py
其他命令
- -s,–strip 可执行文件和共享库将 run through strip. 注意 Cygwin 的 strip 往往使普通的 win32 Dll 无法使用.
- -o DIR, –out=DIR 指定 spec 文件的生成目录, 如果没有指定, 而且当前目录是 PyInstaller 的根目录, 会自动创建一个用于输出 (spec 和生成的可执行文件) 的目录. 如果没有指定, 而当前目录不是 PyInstaller 的根目录, 则会输出到当前的目录下.
- -p DIR, –path=DIR 设置导入路径 (和使用 PYTHONPATH 效果相似). 可以用路径分割符(Windows 使用分号, Linux 使用冒号) 分割, 指定多个目录. 也可以使用多个 - p 参数来设置多个导入路径,让 pyinstaller 自己去找程序需要的资源
- –icon=<FILE.ICO> 将 file.ico 添加为可执行文件的资源 (只对 Windows 系统有效),改变程序的图标 pyinstaller -i ico 路径 xxxxx.py
- –icon=<FILE.EXE,N> 将 file.exe 的第 n 个图标添加为可执行文件的资源 (只对 Windows 系统有效)
- -v FILE, –version=FILE 将 verfile 作为可执行文件的版本资源 (只对 Windows 系统有效)
- -n NAME, –name=NAME 可选的项目 (产生的 spec 的) 名字. 如果省略, 第一个脚本的主文件名将作为 spec 的名字