Hướng dẫn how to save multiple images in python - cách lưu nhiều ảnh trong python

Tôi đang làm việc trong một dự án để xử lý hình ảnh, tôi đã tạo mã để cắt xén và thay đổi kích thước nó, tuy nhiên tôi không biết cách lưu nhiều hình ảnh vào thư mục được nhắm mục tiêu.

Đây là mã của tôi

from os import listdir
from os.path import isfile, join
import numpy
import cv2

filepath = 'DataMentah/akMundur'
onlyfiles = [f for f in listdir(filepath) if isfile(join(filepath))]
images = numpy.empty(len(onlyfiles), dtype = object)
for n in range(0, len(onlyfiles)):
    images[n] = cv2.imread(join(filepath, onlyfiles[n]))
    crp_img = images[0:240, 0:80]
    h = 224
    w = 224
    dimension = (h, w)
    rsz_image = cv2.resize(crp_img, dimension, interpolation = CV2.INTER_AREA)
    #saveimage to targeted folder

Hướng dẫn how to save multiple images in python - cách lưu nhiều ảnh trong python

HALFER

19.7K17 Huy hiệu vàng92 Huy hiệu bạc179 Huy hiệu đồng17 gold badges92 silver badges179 bronze badges

Đã hỏi ngày 31 tháng 5 năm 2020 lúc 7:17May 31, 2020 at 7:17

Hướng dẫn how to save multiple images in python - cách lưu nhiều ảnh trong python

5

Bạn chỉ cần viết hình ảnh và tạo số lượng vòng lặp của tên của tên:

for n in range(0, len(onlyfiles)):
    # other things you need to do snipped
    cv2.imwrite(f'/path/to/destination/image_{n}.png',image)

Bằng cách đó bạn nhận được tên đặt hàng cho nó. Bạn có thể sử dụng ngôn ngữ định dạng mini để định dạng

Requirement already satisfied: tldextract in /opt/anaconda3/lib/python3.7/site-packages (2.2.2)
Requirement already satisfied: requests>=2.1.0 in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (2.22.0)
Requirement already satisfied: setuptools in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (46.0.0.post20200309)
Requirement already satisfied: requests-file>=1.4 in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (1.5.1)
Requirement already satisfied: idna in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (2.8)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /opt/anaconda3/lib/python3.7/site-packages (from requests>=2.1.0->tldextract) (1.25.8)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /opt/anaconda3/lib/python3.7/site-packages (from requests>=2.1.0->tldextract) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in /opt/anaconda3/lib/python3.7/site-packages (from requests>=2.1.0->tldextract) (2019.11.28)
Requirement already satisfied: six in /opt/anaconda3/lib/python3.7/site-packages (from requests-file>=1.4->tldextract) (1.14.0)
5 như vậy:

for n in range(5):
    print(f"filename_{n:04}.png")   # format as 4 digits with leading zeros

Output:

filename_0000.png
filename_0001.png
filename_0002.png
filename_0003.png
filename_0004.png 

Xem Chuỗi định dạng Ngôn ngữ mini để biết thêm các tùy chọn định dạng.

Đã trả lời ngày 31 tháng 5 năm 2020 lúc 7:31May 31, 2020 at 7:31

Hướng dẫn how to save multiple images in python - cách lưu nhiều ảnh trong python

Patrick Artnerpatrick ArtnerPatrick Artner

49,4K8 Huy hiệu vàng45 Huy hiệu bạc68 Huy hiệu Đồng8 gold badges45 silver badges68 bronze badges

0


Kết quả học tập

  • Để tìm hiểu cách tải xuống nhiều hình ảnh trong Python bằng cách sử dụng mã đồng bộ và không đồng bộ.

Tự động tải xuống hình ảnh từ một số trang HTML của bạn là một kỹ năng thiết yếu, trong hướng dẫn này, bạn sẽ học 4 phương pháp về cách tải xuống hình ảnh bằng Python!

Hãy bắt đầu với ví dụ dễ nhất, nếu chúng ta đã có một danh sách các URL hình ảnh thì chúng ta có thể làm theo quy trình này:

  1. Thay đổi thành một thư mục nơi chúng tôi muốn lưu trữ tất cả các hình ảnh.
  2. Thực hiện yêu cầu tải xuống tất cả các hình ảnh, từng cái một.
  3. Chúng tôi cũng sẽ bao gồm xử lý lỗi để nếu URL không còn tồn tại, mã vẫn sẽ hoạt động.

Nhập khẩu Python

!pip install tldextract
Requirement already satisfied: tldextract in /opt/anaconda3/lib/python3.7/site-packages (2.2.2)
Requirement already satisfied: requests>=2.1.0 in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (2.22.0)
Requirement already satisfied: setuptools in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (46.0.0.post20200309)
Requirement already satisfied: requests-file>=1.4 in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (1.5.1)
Requirement already satisfied: idna in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (2.8)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /opt/anaconda3/lib/python3.7/site-packages (from requests>=2.1.0->tldextract) (1.25.8)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /opt/anaconda3/lib/python3.7/site-packages (from requests>=2.1.0->tldextract) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in /opt/anaconda3/lib/python3.7/site-packages (from requests>=2.1.0->tldextract) (2019.11.28)
Requirement already satisfied: six in /opt/anaconda3/lib/python3.7/site-packages (from requests-file>=1.4->tldextract) (1.14.0)
import requests
import os
import subprocess
import urllib.request
from bs4 import BeautifulSoup
import tldextract

!mkdir all_images
!ls

Hướng dẫn how to save multiple images in python - cách lưu nhiều ảnh trong python

Thay đổi thành thư mục của thư mục có tên All_images, điều này có thể được thực hiện bằng một trong hai:

# !cd all_images
# os.chdir('path')
for n in range(0, len(onlyfiles)):
    # other things you need to do snipped
    cv2.imwrite(f'/path/to/destination/image_{n}.png',image)
0
for n in range(0, len(onlyfiles)):
    # other things you need to do snipped
    cv2.imwrite(f'/path/to/destination/image_{n}.png',image)
1

Phương pháp một: Cách tải xuống nhiều hình ảnh từ danh sách Python

Để tải xuống nhiều hình ảnh, chúng tôi sẽ sử dụng thư viện yêu cầu. Chúng tôi cũng sẽ tạo một danh sách Python để lưu trữ bất kỳ URL hình ảnh bị hỏng nào đã trả lại mã trạng thái 200:

for n in range(0, len(onlyfiles)):
    # other things you need to do snipped
    cv2.imwrite(f'/path/to/destination/image_{n}.png',image)
2
for n in range(0, len(onlyfiles)):
    # other things you need to do snipped
    cv2.imwrite(f'/path/to/destination/image_{n}.png',image)
3
for n in range(0, len(onlyfiles)):
    # other things you need to do snipped
    cv2.imwrite(f'/path/to/destination/image_{n}.png',image)
4
for n in range(0, len(onlyfiles)):
    # other things you need to do snipped
    cv2.imwrite(f'/path/to/destination/image_{n}.png',image)
5

Xem nó đơn giản như thế nào! ☝

Nếu bạn kiểm tra thư mục của mình, bây giờ bạn đã tải xuống tất cả các hình ảnh có chứa mã trạng thái 200!



Phương pháp hai: Cách tải xuống nhiều hình ảnh từ nhiều trang web HTML

Nếu chúng tôi không có URL hình ảnh chính xác, chúng tôi sẽ cần phải làm như sau:

  1. Tải xuống nội dung HTML của mỗi trang web.
  2. Trích xuất tất cả các URL hình ảnh cho mỗi trang.
  3. Tạo tên tệp.
  4. Kiểm tra xem mã trạng thái hình ảnh là 200.
  5. Viết tất cả hình ảnh vào máy tính cục bộ của bạn.

Trang web này Internetingishard.com có ​​một số URL hình ảnh tương đối. Do đó, chúng tôi sẽ cần đảm bảo rằng mã của chúng tôi có thể xử lý cho hai loại URL nguồn hình ảnh sau:

  • FilePath chính xác: https://www.iNetingishard.com/html-and-css/links-and-images/html-attributes-6f5690.png
  • FilePath tương đối: /html-and-css/links-and-images/html-attributes-6f5690.png

for n in range(0, len(onlyfiles)):
    # other things you need to do snipped
    cv2.imwrite(f'/path/to/destination/image_{n}.png',image)
6

Chúng tôi cũng sẽ trích xuất miền của mỗi URL trong khi chúng tôi lặp qua các trang web như vậy:

for n in range(0, len(onlyfiles)):
    # other things you need to do snipped
    cv2.imwrite(f'/path/to/destination/image_{n}.png',image)
7
for n in range(0, len(onlyfiles)):
    # other things you need to do snipped
    cv2.imwrite(f'/path/to/destination/image_{n}.png',image)
8
for n in range(0, len(onlyfiles)):
    # other things you need to do snipped
    cv2.imwrite(f'/path/to/destination/image_{n}.png',image)
9
for n in range(5):
    print(f"filename_{n:04}.png")   # format as 4 digits with leading zeros
0

Bây giờ, hãy để kiểm tra kỹ và lọc từ điển của chúng tôi để & nbsp; chúng tôi chỉ nhìn vào các trang web nơi có ít nhất 1 thẻ hình ảnh:we only look at web pages where there was at least 1 image tag:

for n in range(5):
    print(f"filename_{n:04}.png")   # format as 4 digits with leading zeros
1
for n in range(5):
    print(f"filename_{n:04}.png")   # format as 4 digits with leading zeros
2

Một cách dễ dàng hơn để viết mã trên sẽ là thông qua sự hiểu biết từ điển:

for n in range(5):
    print(f"filename_{n:04}.png")   # format as 4 digits with leading zeros
3

Bây giờ chúng ta có thể làm sạch tất cả các URL hình ảnh bên trong mọi khóa từ điển và thay đổi tất cả các đường dẫn URL tương đối sang các đường dẫn URL chính xác.

Hãy bắt đầu bằng cách in ra tất cả các nguồn hình ảnh khác nhau để xem làm thế nào chúng ta có thể cần phải làm sạch dữ liệu dưới đây:

for n in range(5):
    print(f"filename_{n:04}.png")   # format as 4 digits with leading zeros
4

Hướng dẫn how to save multiple images in python - cách lưu nhiều ảnh trong python


Đối với phạm vi của hướng dẫn này, tôi đã quyết định:

  • Xóa liên kết logo bằng //
  • Thêm vào miền vào URL tương đối
for n in range(5):
    print(f"filename_{n:04}.png")   # format as 4 digits with leading zeros
5
for n in range(5):
    print(f"filename_{n:04}.png")   # format as 4 digits with leading zeros
6
for n in range(5):
    print(f"filename_{n:04}.png")   # format as 4 digits with leading zeros
7

Sau khi làm sạch các URL hình ảnh, giờ đây chúng tôi có thể tham khảo Phương thức một để tải xuống hình ảnh vào máy tính của chúng tôi!

Lần này, hãy để Lừa chuyển đổi nó thành một chức năng:

for n in range(5):
    print(f"filename_{n:04}.png")   # format as 4 digits with leading zeros
8
for n in range(5):
    print(f"filename_{n:04}.png")   # format as 4 digits with leading zeros
9
filename_0000.png
filename_0001.png
filename_0002.png
filename_0003.png
filename_0004.png 
0

Hướng dẫn how to save multiple images in python - cách lưu nhiều ảnh trong python


Fantastic!

Bây giờ có một số điều mà chúng tôi đã không nhất thiết phải bao gồm: bao gồm:

  • http: // chỉ URL hình ảnh.
  • http: // www. Chỉ URL hình ảnh.

Nhưng đối với hầu hết các phần, bạn sẽ có thể tải xuống hình ảnh với số lượng lớn!


Cách tăng tốc độ tải xuống hình ảnh của bạn

Khi làm việc với 100 URL hoặc 1000 URL, điều quan trọng là tránh sử dụng phương pháp đồng bộ để tải xuống hình ảnh. Một cách tiếp cận không đồng bộ có nghĩa là chúng ta có thể tải xuống nhiều trang web hoặc nhiều hình ảnh song song.

Điều này có nghĩa là thời gian thực hiện tổng thể sẽ nhanh hơn nhiều!


ThreadPoolExecutor()

ThreadPoolExecutor là một trong những gói I/O được xây dựng trong các gói I/O để tạo ra một hành vi không đồng bộ thông qua nhiều luồng. Để sử dụng nó, chúng tôi sẽ đảm bảo rằng chức năng sẽ chỉ hoạt động trên một URL.

Sau đó, chúng tôi sẽ chuyển danh sách URL hình ảnh vào nhiều công nhân 😉

filename_0000.png
filename_0001.png
filename_0002.png
filename_0003.png
filename_0004.png 
1
filename_0000.png
filename_0001.png
filename_0002.png
filename_0003.png
filename_0004.png 
2
filename_0000.png
filename_0001.png
filename_0002.png
filename_0003.png
filename_0004.png 
3

Mã dưới đây sẽ tạo một thư mục mới và sau đó biến nó thành thư mục hoạt động hiện tại:

filename_0000.png
filename_0001.png
filename_0002.png
filename_0003.png
filename_0004.png 
4
filename_0000.png
filename_0001.png
filename_0002.png
filename_0003.png
filename_0004.png 
5

Bạn nên tải xuống hình ảnh nhưng với tốc độ nhanh hơn nhiều!


Lập trình không đồng bộ!

Giống như JavaScript, Python 3.6+ đi kèm với sự hỗ trợ bản địa cho các đồng hành được gọi là Asyncio. Tương tự như NodeJS, có một phương thức có sẵn cho bạn để tạo các vòng lặp sự kiện tùy chỉnh cho mã async.

Chúng tôi cũng sẽ cần tải xuống thư viện yêu cầu HTTP mã ASYNC được gọi là Aiohttp

filename_0000.png
filename_0001.png
filename_0002.png
filename_0003.png
filename_0004.png 
6

Chúng tôi cũng sẽ tải xuống AIofiles cho phép chúng tôi viết nhiều tệp hình ảnh không đồng bộ:

filename_0000.png
filename_0001.png
filename_0002.png
filename_0003.png
filename_0004.png 
7
filename_0000.png
filename_0001.png
filename_0002.png
filename_0003.png
filename_0004.png 
8
filename_0000.png
filename_0001.png
filename_0002.png
filename_0003.png
filename_0004.png 
9

Cách tải xuống 1 tệp Asychronousy

!pip install tldextract
0
!pip install tldextract
1
!pip install tldextract
2
!pip install tldextract
3

Chúng tôi sẽ cần cấu trúc mã của chúng tôi hơi khác nhau để phiên bản Async hoạt động trên nhiều tệp:

  1. Chúng tôi sẽ có một chức năng tìm nạp để truy vấn mọi URL hình ảnh.
  2. Chúng tôi sẽ có một chức năng chính tạo ra, sau đó thực hiện một loạt các đồng hành.
!pip install tldextract
4
!pip install tldextract
5
!pip install tldextract
6

Hướng dẫn how to save multiple images in python - cách lưu nhiều ảnh trong python

Lưu ý rằng khi chúng ta gọi chức năng này, nó thực sự không chạy và tạo ra một đồng hành! ☝


Sau đó, chúng ta có thể sử dụng Asyncio làm phương thức để thực hiện tất cả các thiết bị gọi tìm nạp cần được hoàn thành:

Nếu bạn nhận được loại lỗi này khi chạy lệnh sau:

!pip install tldextract
7

Hướng dẫn how to save multiple images in python - cách lưu nhiều ảnh trong python

Có khả năng bởi vì bạn đang cố gắng chạy Asyncio trong một vòng lặp sự kiện không thể thực hiện được. (Notebook Jupyter chạy trong một vòng lặp sự kiện!).

Theo thiết kế Asyncio không cho phép vòng lặp sự kiện của nó được lồng nhau. Điều này thể hiện một vấn đề thực tế: khi trong một môi trường mà vòng lặp sự kiện đã chạy, nó không thể chạy các nhiệm vụ và chờ kết quả. Cố gắng làm như vậy sẽ đưa ra lỗi Lỗi RunTimeError: Vòng lặp sự kiện này đã chạy.

Do đó, bạn sẽ cần sử dụng thư viện Nest-Asyncio khi sử dụng máy tính xách tay Jupyter.

!pip install tldextract
8

Cách tải xuống nhiều tệp Python bên trong tệp Python (.py)

Hãy để lưu bộ biến chứa URL của chúng tôi vào tệp .txt:

!pip install tldextract
9

Tạo một tệp Python

Sau đó, bạn sẽ cần tạo một tệp Python và thêm mã sau vào nó:

Requirement already satisfied: tldextract in /opt/anaconda3/lib/python3.7/site-packages (2.2.2)
Requirement already satisfied: requests>=2.1.0 in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (2.22.0)
Requirement already satisfied: setuptools in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (46.0.0.post20200309)
Requirement already satisfied: requests-file>=1.4 in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (1.5.1)
Requirement already satisfied: idna in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (2.8)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /opt/anaconda3/lib/python3.7/site-packages (from requests>=2.1.0->tldextract) (1.25.8)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /opt/anaconda3/lib/python3.7/site-packages (from requests>=2.1.0->tldextract) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in /opt/anaconda3/lib/python3.7/site-packages (from requests>=2.1.0->tldextract) (2019.11.28)
Requirement already satisfied: six in /opt/anaconda3/lib/python3.7/site-packages (from requests-file>=1.4->tldextract) (1.14.0)
0

Sau đó chạy tập lệnh Python trong & nbsp; dòng thiết bị đầu cuối / lệnh của bạn với:either your terminal / command line with:

Requirement already satisfied: tldextract in /opt/anaconda3/lib/python3.7/site-packages (2.2.2)
Requirement already satisfied: requests>=2.1.0 in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (2.22.0)
Requirement already satisfied: setuptools in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (46.0.0.post20200309)
Requirement already satisfied: requests-file>=1.4 in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (1.5.1)
Requirement already satisfied: idna in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (2.8)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /opt/anaconda3/lib/python3.7/site-packages (from requests>=2.1.0->tldextract) (1.25.8)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /opt/anaconda3/lib/python3.7/site-packages (from requests>=2.1.0->tldextract) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in /opt/anaconda3/lib/python3.7/site-packages (from requests>=2.1.0->tldextract) (2019.11.28)
Requirement already satisfied: six in /opt/anaconda3/lib/python3.7/site-packages (from requests-file>=1.4->tldextract) (1.14.0)
1

Hãy cùng phá vỡ những gì mà xảy ra trong đoạn mã trên:

  1. Chúng tôi đang nhập tất cả các gói có liên quan để lập trình Async với các tệp.
  2. Sau đó, chúng tôi tạo một thư mục mới.
  3. Sau khi tạo thư mục mới, chúng tôi thay đổi thư mục đó thành thư mục làm việc đang hoạt động.
  4. Sau đó chúng tôi đọc dữ liệu biến đã được lưu trước đó từ tệp có tên Image.txt
  5. Sau đó, chúng tôi tạo ra một loạt các đồng hành và thực hiện chúng trong hàm chính () với asyncio.
  6. Vì các đồng hành này được thực thi, mỗi tệp đều được lưu không đồng bộ vào máy tính của bạn.

Cuối cùng, hãy để rõ ràng và xóa tất cả các thư mục để làm sạch môi trường của chúng tôi:

Requirement already satisfied: tldextract in /opt/anaconda3/lib/python3.7/site-packages (2.2.2)
Requirement already satisfied: requests>=2.1.0 in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (2.22.0)
Requirement already satisfied: setuptools in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (46.0.0.post20200309)
Requirement already satisfied: requests-file>=1.4 in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (1.5.1)
Requirement already satisfied: idna in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (2.8)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /opt/anaconda3/lib/python3.7/site-packages (from requests>=2.1.0->tldextract) (1.25.8)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /opt/anaconda3/lib/python3.7/site-packages (from requests>=2.1.0->tldextract) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in /opt/anaconda3/lib/python3.7/site-packages (from requests>=2.1.0->tldextract) (2019.11.28)
Requirement already satisfied: six in /opt/anaconda3/lib/python3.7/site-packages (from requests-file>=1.4->tldextract) (1.14.0)
2
Requirement already satisfied: tldextract in /opt/anaconda3/lib/python3.7/site-packages (2.2.2)
Requirement already satisfied: requests>=2.1.0 in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (2.22.0)
Requirement already satisfied: setuptools in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (46.0.0.post20200309)
Requirement already satisfied: requests-file>=1.4 in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (1.5.1)
Requirement already satisfied: idna in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (2.8)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /opt/anaconda3/lib/python3.7/site-packages (from requests>=2.1.0->tldextract) (1.25.8)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /opt/anaconda3/lib/python3.7/site-packages (from requests>=2.1.0->tldextract) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in /opt/anaconda3/lib/python3.7/site-packages (from requests>=2.1.0->tldextract) (2019.11.28)
Requirement already satisfied: six in /opt/anaconda3/lib/python3.7/site-packages (from requests-file>=1.4->tldextract) (1.14.0)
3
Requirement already satisfied: tldextract in /opt/anaconda3/lib/python3.7/site-packages (2.2.2)
Requirement already satisfied: requests>=2.1.0 in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (2.22.0)
Requirement already satisfied: setuptools in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (46.0.0.post20200309)
Requirement already satisfied: requests-file>=1.4 in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (1.5.1)
Requirement already satisfied: idna in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (2.8)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /opt/anaconda3/lib/python3.7/site-packages (from requests>=2.1.0->tldextract) (1.25.8)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /opt/anaconda3/lib/python3.7/site-packages (from requests>=2.1.0->tldextract) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in /opt/anaconda3/lib/python3.7/site-packages (from requests>=2.1.0->tldextract) (2019.11.28)
Requirement already satisfied: six in /opt/anaconda3/lib/python3.7/site-packages (from requests-file>=1.4->tldextract) (1.14.0)
4

Có thể tải xuống hình ảnh với Python cho phép bạn mở rộng khả năng tự động hóa của mình và những chương trình khác, API, v.v. Bạn có thể sử dụng dữ liệu hình ảnh đó!

Hy vọng bây giờ bạn cảm thấy tự tin về việc tải xuống hình ảnh trong Python ❤

Phản ứng của bạn là gì?

Trang web này chứa các liên kết đến một số trang web của bên thứ ba được mô tả là liên kết liên kết. Các liên kết liên kết này cho phép chúng tôi có được một khoản hoa hồng nhỏ khi bạn nhấp và mua sản phẩm trên các trang web đó (nó không tốn kém gì thêm!). AttackData.com là người tham gia Chương trình Associates Associates của Amazon Services, một chương trình quảng cáo liên kết được thiết kế để cung cấp phương tiện cho chủ sở hữu trang web để kiếm phí quảng cáo bằng cách quảng cáo và liên kết với Amazon và bất kỳ trang web nào khác có thể liên kết với chương trình AMAZON Service LLC Associates .