Error in user YAML: (<unknown>): found a tab character that violate indentation while scanning a plain scalar at line 3 column 3
---
- oeasy Python 0070
- 这是 oeasy 系统化 Python 教程,从基础一步步讲,扎实、完整、不跳步。愿意花时间学,就能真正学会。
- 本教程同步发布在:
- 个人网站: `https://oeasy.org`
- 蓝桥云课: `https://www.lanqiao.cn/courses/3584`
- GitHub: `https://github.com/overmind1980/oeasy-python-tutorial`
- Gitee: `https://gitee.com/overmind1980/oeasypython`
---- 配套视频
- 新函数 dir
- 可以查询
- 模块中的成员
-
游乐场里面 已经有了一些函数
- help
- dir
- quit
- 这些函数 位于
__builtins__模块 - 所以都是 内建函数
-
可以把 这个
__builtins__删除掉吗?
- 按q
- 退出帮助
del __builtins__
- 效果
- 内建模块
- 可以删除
- 没有报错
- 瞬间重生
- 可以 导入
- 外部模块 吗?
- 导入命令 是
- import
- port是港口
- import 是进口 、 导入
- export 是出口 、 导出
- import 后面
接空格
- import
- 被导入的模块 是
__hello__- 读作
dunder hello - 注意 hello 两边
- 都有dunder(双下划线)
import __hello__
- 把
__hello__模块 导入到游乐场
- 可以 输出那句 hello world
- 注意!
- 观察导入前后变化
- 导入
__hello__模块后- 游乐场中的模块 增加了
- 导入 对应关键词
- import
- 怎么 理解 来着?
- 进口(import)
- 导入模块
- 可以导入 各种模块 来增强功能
- 想要深入了解
__hello__- 应该怎么办呢?
- 什么不会就 help什么
help(__hello__)
- 使用help函数 查询手册
__hello__是- 非常简单的
- 一个模块
- 里面有个成员变量
- initialized
- 可以看看吗?
dir(__hello__)
- 观察模块
- 确实如help所说
- 有个成员initialized
- 值为True
为什么要引入 模块 呢?
- 我们可以通过
- 引入
__hello__- 完成输出
Hello world!
- 完成输出
- 引入
traceback- 使用跟踪调试
- 引入
time- 查看时间
- 设置延时
- 引入
- time模块里面有个asctime函数
- 可以得到当前时间
- asctime 中的 asc 什么意思来着?
- asc的意思是ascii
- 是 7-bit的
- 字符和序号的固定对应关系
-
黑暗森林 上半区
- 至今还是黑的
-
可以导入多个文件吗?😱
- 根据 下图建议
- 不同模块
- 分行导入
- 各种 模块
- 各自身怀绝技
- 可以配合起来使用
- 有什么 好玩的 模块 吗?
- 在vim的正常模式下
- 键入:!python3
- 进入游乐场
- 在游乐场中键入
- import antigravity
- 玩完了之后
- ctrl + d 退出游乐场
- 回到vim
- 可以通过vim
- 看到 python的 许可证
vi /usr/lib/python3.8/LICENSE.txt
- 这段历史
- 我们见证过
- Guido的个人简历
- 我想把 许可证 的 文本
- 做成 词云图
- 尝试 加载
- 分词模块 jieba
- 词云模块 WordCloud
- 画图模块 matplotlib
import jieba
from wordcloud import WordCloud
import matplotlib.pyplot as plt
# 读取文件
with open('/usr/lib/python3.8/LICENSE.txt') as file:
text = file.read()
# 使用jieba进行中文分词
words = ' '.join(jieba.cut(text))
# 生成词云
wordcloud = WordCloud(font_path='/usr/share/fonts/truetype/wqy/wqy-microhei.ttc', # 指定中文字体路径
width=800, height=600,
background_color='white').generate(words)
# 使用matplotlib展示词云
plt.imshow(wordcloud, interpolation='bilinear')
plt.axis('off')
plt.show()- ModuleError
- 找不到模块
- 安装模块
:term
- 在上面开启 shell终端窗口
- 上面的shell中
- 粘贴命令
pip install wordcloud
pip install matplotlib
pip install jieba- 在shell中安装类库
- 在上面的shell中exit退出
- 安装类库后
- 再运行当前程序
- 成功展示了 词云 图
- 可以考虑修改
- 高度
- 宽度
- 背景颜色
- 这都是细节
- 问ai就能解决
-
模块 就是 封装好功能 的 部件
- 如 wifi模块
-
导入
__hello__module模块- 可以 输出
hello world! - 看起来很简单
- 可以 输出
- 我想要做个
自己的模块- 能行吗??🤔
- 我们下次再说!👋
- 配套视频
- 本文来自 oeasy Python 系统教程。
- 想完整、扎实学 Python,
- 搜索 oeasy 即可。


















