Xem thảo luận
Cải thiện bài viết
Lưu bài viết
Xem thảo luận
Cải thiện bài viết
Lưu bài viết
Đọcsave[] function. save[]
function saves the image into
the file or filename. It saves the final manipulated image in your disk.
Bàn luận
Bất cứ khi nào chúng tôi thao tác với một hình ảnh và muốn lưu giữ hình ảnh để biết thêm hình ảnh, chúng tôi sẽ sử dụng hàm Save []. Hàm
save[]
lưu hình ảnh vào tệp hoặc tên tệp. Nó lưu hình ảnh được thao tác cuối cùng trong đĩa của bạn.A compressed file named koala.jpg.gz get saved in disk1A compressed file named koala.jpg.gz get saved in disk2=
A compressed file named koala.jpg.gz get saved in disk4A compressed file named koala.jpg.gz get saved in disk5Cú pháp:
It has only two parameter and takes only one at a time.
wand.image.save[
file
=
________ 9 ________ 10 & nbsp;Tham số: Nó chỉ có hai tham số và chỉ mất một tham số.Tham sốKiểu đầu vào Sự mô tả tập tin đối tượng tệp một đối tượng tệp để ghi vào tham số tệp Tên tệp
Basestring
một đối tượng tên tệp để ghi vào tham số tệp Save image to the disk.
Bây giờ, hãy để xem mã để lưu hình ảnh.
numpy.save[file, arr, allow_pickle=True, fix_imports=True]0
=
numpy.save[file, arr, allow_pickle=True, fix_imports=True]2
numpy.save[file, arr, allow_pickle=True, fix_imports=True]3
Ví dụ #1: Lưu hình ảnh vào đĩa.
numpy.save[file, arr, allow_pickle=True, fix_imports=True]4
>>> import numpy as np
>>> from tempfile import TemporaryFile
>>> outfile = TemporaryFile[]
>>> a = np.arange[12]
>>> np.save[outfile, a]
>>> outfile.seek[0] # Only needed here to simulate closing & reopening file
>>> np.load[outfile]
0=
>>> import numpy as np
>>> from tempfile import TemporaryFile
>>> outfile = TemporaryFile[]
>>> a = np.arange[12]
>>> np.save[outfile, a]
>>> outfile.seek[0] # Only needed here to simulate closing & reopening file
>>> np.load[outfile]
2A compressed file named koala.jpg.gz get saved in disk5
A compressed file named koala.jpg.gz get saved in disk
6 A compressed file named koala.jpg.gz get saved in disk
7A compressed file named koala.jpg.gz get saved in disk
8 A compressed file named koala.jpg.gz get saved in disk
9
In output an image named koala.png will be saved in disk
numpy.save[file, arr, allow_pickle=True, fix_imports=True]
4numpy.save[file, arr, allow_pickle=True, fix_imports=True]
5numpy.save[file, arr, allow_pickle=True, fix_imports=True]
6 numpy.save[file, arr, allow_pickle=True, fix_imports=True]
7 numpy.save[file, arr, allow_pickle=True, fix_imports=True]
8
Đầu ra:
Ví dụ #2:
Bây giờ, hãy để xem mã để lưu hình ảnh.
Ví dụ #1: Lưu hình ảnh vào đĩa.
numpy.save[file, arr, allow_pickle=True, fix_imports=True]0
=
array[[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]]9
numpy.save[file, arr, allow_pickle=True, fix_imports=True]3
A compressed file named koala.jpg.gz get saved in disk6
A compressed file named koala.jpg.gz get saved in disk7
A compressed file named koala.jpg.gz get saved in disk8
A compressed file named koala.jpg.gz get saved in disk9
numpy.save[file, arr, allow_pickle=True, fix_imports=True]4
numpy.save[file, arr, allow_pickle=True, fix_imports=True]5
numpy.save[file, arr, allow_pickle=True, fix_imports=True]6
numpy.save[file, arr, allow_pickle=True, fix_imports=True]7
numpy.save[file, arr, allow_pickle=True, fix_imports=True]8
wand.image.save[
1
A compressed file named koala.jpg.gz get saved in disk
6 A compressed file named koala.jpg.gz get saved in disk
7A compressed file named koala.jpg.gz get saved in disk
8 A compressed file named koala.jpg.gz get saved in disk
9
A compressed file named koala.jpg.gz get saved in disk
chức năng numpy.save []
Hàm Save [] được sử dụng để lưu một mảng vào tệp nhị phân ở định dạng .npy numpy.
Syntax:
numpy.save[file, arr, allow_pickle=True, fix_imports=True]
Phiên bản: 1.15.0 1.15.0
Parameter:
tập tin | Tệp hoặc tên tệp mà dữ liệu được lưu. Nếu tệp là một đối tượng tệp, thì tên tệp không thay đổi. Nếu tệp là một chuỗi hoặc đường dẫn, tiện ích mở rộng .npy sẽ được gắn vào tên tệp nếu nó chưa có. Tệp, str hoặc pathlib.path If file is a string or Path, a .npy extension will be appended to the file name if it does not already have one. file, str, or pathlib.Path | Yêu cầu |
mảng | Dữ liệu mảng sẽ được lưu. Array_Like array_like | Yêu cầu |
mảng | Dữ liệu mảng sẽ được lưu. Array_Like [loading pickled data can execute arbitrary code] and portability [pickled objects may not be loadable on different Python installations, for example if the stored objects require libraries that are not available, and not all pickled data is compatible between Python 2 and Python 3]. Default: True bool | Không bắt buộc |
Fix_Imports | Chỉ hữu ích trong việc buộc các đối tượng trong các mảng đối tượng trên Python 3 được ngâm theo cách tương thích Python 2. Nếu Fix_Imports là đúng, Pickle sẽ cố gắng ánh xạ các tên Python 3 mới cho các tên mô -đun cũ được sử dụng trong Python 2, để luồng dữ liệu Pickle có thể đọc được với Python 2. Bool If fix_imports is True, pickle will try to map the new Python 3 names to the old module names used in Python 2, so that the pickle data stream is readable with Python 2. bool | Không bắt buộc |
Ghi chú: Để biết mô tả về định dạng .npy, xem numpy.lib.format.
For a description of the .npy format, see numpy.lib.format.
Numpy.save [] Phương thức Ví dụ:
Lưu trữ dữ liệu vào đĩa và tải lại:
>>> import numpy as np
>>> from tempfile import TemporaryFile
>>> outfile = TemporaryFile[]
>>> a = np.arange[12]
>>> np.save[outfile, a]
>>> outfile.seek[0] # Only needed here to simulate closing & reopening file
>>> np.load[outfile]
Output:
array[[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]]
Python - Trình chỉnh sửa mã Numpy:
Trước: tải [] functionNext: savez [] hàm load[] function
Next:
savez[] function