成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

七個令人瞠目結舌的Python庫

開發 前端
除了Python本身的強大功能之外,還有許多令人瞠目結舌的Python庫,它們為開發者們帶來了無盡的驚喜和創造力。在本文中,筆者為大家分享7個這樣的Python庫,建議收藏。

在編程的世界中,Python一直以其簡潔、易讀的語法而備受推崇。然而,除了Python本身的強大功能之外,還有許多令人瞠目結舌的Python庫,它們為開發者們帶來了無盡的驚喜和創造力。在本文中,筆者為大家分享7個這樣的Python庫,建議收藏。

1. rembg

rembg是一個強大的Python庫,用于圖像背景的自動去除。它基于深度學習和人工智能技術,能夠高度準確地將圖像中的背景摳出,留下前景圖像。

安裝rembg:

#Installation
pip install rembg

示例:

# Importing libraries
from rembg import remove
import cv2 
# path of input image (my file: image.jpeg)
input_path = 'demo.jpg'
# path for saving output image and saving as a output.jpeg
output_path = 'output.jpg'
# Reading the input image
input = cv2.imread(input_path)
# Removing background
output = remove(input)
# Saving file 
cv2.imwrite(output_path, output)

2. Ipyvolume

Ipyvolume是一個基于Jupyter Notebook的Python庫,用于創建交互式的3D可視化和動畫。它提供了豐富的功能和工具,使得在Notebook中可視化數據變得更加簡單和直觀。

示例代碼:

from colormaps import parula
X = np.arange(-5, 5, 0.25*1)
Y = np.arange(-5, 5, 0.25*1)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)
Z = np.sin(R)

colormap = parula
znorm = Z - Z.min()
znorm /= znorm.ptp()
znorm.min(), znorm.max()
color = colormap(znorm)
ipv.figure()
mesh = ipv.plot_surface(X, Z, Y, color=color[...,:3])
ipv.show()

3. Pandas-Bokeh

Pandas-Bokeh是一個使用Bokeh為Pandas數據幀提供交互式繪圖的庫,它對于創建交互式可視化數據非常有用。

安裝pandas-bokeh:

pip install pandas-bokeh

交互式可視化效果:

示例代碼:

import pandas as pd
import pandas_bokeh

data = {
    'fruits':
    ['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries'],
    '2015': [2, 1, 4, 3, 2, 4],
    '2016': [5, 3, 3, 2, 4, 6],
    '2017': [3, 2, 4, 4, 5, 3]
}
df = pd.DataFrame(data).set_index("fruits")

p_bar = df.plot_bokeh.bar(
    ylabel="Price per Unit [€]", 
    title="Fruit prices per Year", 
    alpha=0.6)

4. Humanize

Humanize是一個Python庫,旨在將復雜的數據類型和單位轉換為更易讀的形式,以增加人類可理解性。它提供了一些有用的函數,用于將數字、時間、文件大小等轉換為更友好和可讀性強的格式。

使用Humanize庫,你可以將整數轉換為帶有逗號的易讀形式,例如將1000轉換為"1,000";將時間間隔轉換為更具描述性的形式,例如將60秒轉換為"1分鐘";將字節數轉換為更易理解的文件大小表示,例如將1024轉換為"1KB"。

安裝Humanize:

pip install Humanize

示例(integers):

# Importing library

import humanize
import datetime as dt

# Formatting  numbers with comma
a =  humanize.intcomma(951009)

# converting numbers into words
b = humanize.intword(10046328394)

#printing

print(a)
print(b)

輸出:

951,009 10.0 billion

示例(Date&Time):

import humanize
import datetime as dt

a = humanize.naturaldate(dt.date(2023, 9,7))
b = humanize.naturalday(dt.date(2023, 9,7))

print(a)
print(b)

輸出:

today
today

5. Pendulum

Pendulum擴展了內置的Python DateTime模塊,添加了一個更直觀的API,用于處理時區,對日期和時間進行操作,如添加時間間隔、刪去日期以及在時區之間進行轉換。它為格式化日期和時間提供了一個簡單、人性化的API。

安裝Pendulum:

pip install pendulum

示例:

# import library
import pendulum

dt = pendulum.datetime(2023, 8, 31)
print(dt)
 
#local() creates datetime instance with local timezone

local = pendulum.local(2023, 8, 31)
print("Local Time:", local)
print("Local Time Zone:", local.timezone.name)

# Printing UTC time
utc = pendulum.now('UTC')
print("Current UTC time:", utc)
 
# Converting UTC timezone into Europe/Paris time

europe = utc.in_timezone('Europe/Paris')
print("Current time in Paris:", europe)

輸出:

2023-08-31T00:00:00+00:00 

Local Time: 2023-08-31T00:00:00+08:00 

Local Time Zone: Asia/Shanghai Current 

UTC time: 2023-09-07T04:06:05.436553+00:00 

Current time in Paris: 2023-09-07T06:06:05.436553+02:00

6. Sketchpy

Sketchpy是一個用于對圖像進行動畫繪制的Python模塊。sketchpy模塊是在Python中的turtle模塊之上創建的。

安裝Sketchpy:

pip install sketchpy

示例-使用 Python 繪制 Vijay:

from sketchpy import library
myObject = library.vijay()
myObject.draw()

7. FTFY

FTFY是一個Python庫,它的全稱是"Fixes Text For You",用于修復和糾正文本中的常見編碼問題和Unicode字符問題。它可以自動檢測和修復各種編碼問題,使得文本在處理和顯示時更加準確和一致。

安裝FTFY:

pip install ftfy

示例:

print(ftfy.fix_text('Correct the sentence using a€?ftfya€\x9d.'))
print(ftfy.fix_text('a?” No problems with text'))
print(ftfy.fix_text('? perturber la r??flexion'))

輸出:

責任編輯:趙寧寧 來源: 郭小喵玩AI
相關推薦

2013-09-25 09:18:59

2025-03-04 08:40:00

AI游戲訓練

2014-11-28 09:02:48

千兆寬帶

2014-10-29 15:11:35

Cocos Studi

2017-06-21 12:43:47

互聯網

2011-06-29 13:22:58

CSS3

2009-04-14 08:38:40

2021-09-22 12:45:47

Python數據分析

2025-02-17 11:10:49

2023-10-08 09:52:55

2024-04-29 07:53:22

Go語言Go-cli 項目工具

2017-12-18 17:03:56

Python程序員開發

2023-06-04 17:13:26

.NET開發應用程序

2020-07-15 15:38:15

人臉識別照片活化手機

2017-04-11 21:03:50

機器人智能化人工智能

2009-06-17 09:41:33

Facebook即時通FbChat

2022-05-23 11:13:02

Python工具

2023-03-07 16:09:08

2024-08-30 14:29:03

2024-11-06 16:45:39

Python游戲開發代碼
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 亚洲成人三级 | 国产精品久久久久久一级毛片 | 免费一级毛片 | 国产精品免费福利 | 亚洲午夜av| 国产91久久精品一区二区 | 999久久久| 成人教育av | 午夜成人免费视频 | 丝袜毛片 | 久久国产精品一区二区 | 亚洲第一成人影院 | 国产一区二区三区在线 | 男女污网站 | 日韩久久综合网 | 欧美国产精品一区二区三区 | 欧美精品一二三区 | 97av视频在线观看 | 日韩一区二区三区在线看 | 天天躁天天操 | 国产精品日本一区二区在线播放 | 中文字幕精品一区 | 欧美日韩在线一区二区 | 国产精品亚洲第一区在线暖暖韩国 | 一区二区在线观看av | 精品亚洲第一 | 黄色网址在线免费观看 | 亚洲欧美激情网 | 综合一区二区三区 | 99re在线视频| 玖玖国产| 日韩三级在线 | 亚洲草草视频 | 激情av网站 | 国产精品久久久久aaaa九色 | 国产成人精品免费视频大全最热 | 国产精品视频导航 | 在线观看国产h | 在线观看 亚洲 | 成人h动漫亚洲一区二区 | 免费一区|