任务-Python 包

几个 python

进度条和 tqdm:
为循环、文件处理或下载等任务实现进度条。

from progress.bar import chargingbarbar = chargingbar('processing', max=20)for i in range(20):    # do some work    bar.next()bar.finish()

输出:

processing ████████████████████████████████ 100%

tqdm:与进度条类似,但设置比进度条更简单。

from tqdm import tqdmimport timefor i in tqdm(range(100)):    time.sleep(0.1)

输出:

100%|██████████████████████████████████████| 100/100 [00:00<00:00, 18784.11it/s]

matplotlib:

matplotlib 用于创建静态、动画和交互式可视化。

import matplotlib.pyplot as pltx = [1, 2, 3, 4, 5]y = [2, 4, 6, 8, 10]plt.plot(x, y, label='linear growth', color='blue', linestyle='--', marker='o')plt.title("line plot example")plt.xlabel("x-axis")plt.ylabel("y-axis")plt.legend()plt.show()

输出:

任务-Python 包

numpy:
numpy(数值 python)是用于数值计算的基本 python 库。它支持处理大型多维数组(如一维、二维、三维)和矩阵,以及一组数学函数以有效地对这些数组进行操作。

示例:

import numpy as np# 1d arrayarr1 = np.array([1, 2, 3, 4])# 2d arrayarr2 = np.array([[1, 2], [3, 4]])print(arr1, arr2)

输出:

[1 2 3 4] [[1 2] [3 4]]

熊猫:
它用于使用series(列表)和dataframe(表格或电子表格)进行数据操作和分析。

示例:

import pandasx=[1,2,3]y=pandas.series(x,index=["no1","no2","no3"])print(y)

输出:

no1    1no2    2no3    3dtype: int64

以上就是任务-Python 包的详细内容,更多请关注创想鸟其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/1354712.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2025年12月13日 18:45:33
下一篇 2025年12月13日 18:45:37

相关推荐

发表回复

登录后才能评论
关注微信