av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

七個令人瞠目結(jié)舌的Python庫

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

1. rembg

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

安裝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庫,用于創(chuàng)建交互式的3D可視化和動畫。它提供了豐富的功能和工具,使得在Notebook中可視化數(shù)據(jù)變得更加簡單和直觀。

示例代碼:

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數(shù)據(jù)幀提供交互式繪圖的庫,它對于創(chuàng)建交互式可視化數(shù)據(jù)非常有用。

安裝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庫,旨在將復(fù)雜的數(shù)據(jù)類型和單位轉(zhuǎn)換為更易讀的形式,以增加人類可理解性。它提供了一些有用的函數(shù),用于將數(shù)字、時間、文件大小等轉(zhuǎn)換為更友好和可讀性強的格式。

使用Humanize庫,你可以將整數(shù)轉(zhuǎn)換為帶有逗號的易讀形式,例如將1000轉(zhuǎn)換為"1,000";將時間間隔轉(zhuǎn)換為更具描述性的形式,例如將60秒轉(zhuǎn)換為"1分鐘";將字節(jié)數(shù)轉(zhuǎn)換為更易理解的文件大小表示,例如將1024轉(zhuǎn)換為"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擴展了內(nèi)置的Python DateTime模塊,添加了一個更直觀的API,用于處理時區(qū),對日期和時間進行操作,如添加時間間隔、刪去日期以及在時區(qū)之間進行轉(zhuǎn)換。它為格式化日期和時間提供了一個簡單、人性化的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模塊之上創(chuàng)建的。

安裝Sketchpy:

pip install sketchpy

示例-使用 Python 繪制 Vijay:

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

7. FTFY

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

安裝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'))

輸出:


當(dāng)前標(biāo)題:七個令人瞠目結(jié)舌的Python庫
本文網(wǎng)址:http://uogjgqi.cn/article/dpsjcsg.html
掃二維碼與項目經(jīng)理溝通

我們在微信上24小時期待你的聲音

解答本文疑問/技術(shù)咨詢/運營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流