如何导入模块_导入模块的作用_hello_dunder_双下划线
回忆上次内容
-
游乐场里面 已经有了一些函数
-
help
-
dir
-
quit
-
print
-
这些函数 位于 __builtins__ 模块
-
所以都是 内建函数
-
导入命令 是
-
import
-
port是港口
-
import 是进口 、 导入
-
export 是出口 、 导出
-
被导入的模块 是
-
__hello__
-
读作 dunder hello
-
注意 hello 两边
-
都有dunder(双下划线)
-
导入 __hello__模块后
-
游乐场中的模块 增加了
-
导入 对应关键词
-
import
-
怎么 理解 来着?
-
进口(import)
-
导入模块
-
可以导入 各种模块 来增强功能
-
__hello__ 是
-
非常简单的
-
一个模块
-
里面有个成员变量
-
initialized
-
确实如help所说
-
有个成员initialized
-
值为True
-
我们可以通过
-
引入__hello__
-
完成输出 Hello world!
-
time模块里面有个asctime函数
-
可以得到当前时间
-
asc的意思是ascii
-
是 7-bit的
-
字符和序号的固定对应关系
-
在vim的正常模式下
-
键入:!python3
-
进入游乐场
-
在游乐场中键入
-
import antigravity
-
玩完了之后
-
ctrl + d 退出游乐场
-
回到vim
vi /usr/lib/python3.8/LICENSE.txt
-
尝试 加载
-
分词模块 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()
pip install wordcloud pip install matplotlib pip install jieba
-
模块 就是 封装好功能 的 部件
-
如 wifi模块
-
导入 __hello__ module模块
-
可以 输出hello world!
-
看起来很简单
-
我们下次再说!????
-
蓝桥->
-
github->
-
gitee->