Python

Python: NumPy 的二進制檔案 .npy

np.save

numpy.save(file, arr, allow_pickle=True, fix_imports=True)
  • file:file, str, or pathlib.Path
    儲存檔名或路徑。
  • arr:array_like
    要保存的NumPy陣列變數資料。

寫入 .npy 檔

with open("test.npy", "wb") as f:
    np.save(f, np.array([1, 2]))
    np.save(f, np.array([1, 3]))

讀取 .npy 檔

with open("test.npy", "rb") as f:
    a = np.load(f)
    b = np.load(f)

print(a, b)
# [1 2] [1 3]

np.savez

numpy.savez(file, *args, **kwds)
  • file:str or file
    儲存檔名或路徑。
  • args:Arguments, optional
    要保存NumPy陣列變數資料。會自動使用關鍵字參數(請參閱下面的 kwds)為陣列分配名稱。指定為 args 的數組將命名為“arr_0”、“arr_1”等。
  • kwds:Keyword arguments, optional
    要保存到文件的數組。每個數組都將保存到輸出文件及其對應的關鍵字名稱。

使用 *args 參數來儲存 (會預設名稱)

np.savez(outfile, x, y)
_ = outfile.seek(0) # Only needed here to simulate closing & reopening file
npzfile = np.load(outfile)
npzfile.files
['arr_0', 'arr_1']
npzfile['arr_0']
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])

使用 **kwds 參數來儲存 (自定義名稱)

outfile = TemporaryFile()
np.savez(outfile, x=x, y=y)
_ = outfile.seek(0)
npzfile = np.load(outfile)
sorted(npzfile.files)
['x', 'y']
npzfile['x']
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])

參考

3,459 則留言

  • rsjrtqdsq

    There are no comments for 1940s Style Aviator Pin-up Girl Posing.   Click here to post the first comment. Users who want to play the Pin Up Aviator game on the go with maximum convenience can download the free mobile casino app for Android. We can confirm it is highly optimized, works fast, and includes a full set of Pin Up options. Here are the instructions on how to get it: Yes, it is. Pin Up Casino is regulated by the government of Curacao, which, in turn, protects gamblers’ rights while they are placing bets here. Moreover, the gambling site cannot manipulate the results as they are calculated on the game server’s side. (I actually did a vintage pin up boudoir shoot before our wedding! Yes, I kept that one quiet didn’t I?) The download and installation process for the Pin Up iOS app is the same. Once the download finishes, the installation will automatically begin on your device.  After a successful installation, you’ll find the Pin Up app icon on your home screen or app menu.
    https://duriandeck.borangjualan.com/2025/05/pinup-aviator-oyunculari-ucun-xususiyy%c9%99tl%c9%99rin-icmali/
    Aviator-da oyununuzu inkişaf etdirmək istəyirsinizsə, pulsuz Aviator Predictor sizə gözəl təkan verir. Aviator canlı proqnoz tətbiqini endirin və quraşdırın, daha sonra giriş edin və ya qeydiyyatdan keçin. Tətbiqdə Predictor funksiyasını aktivləşdirin və mərc etməzdən əvvəl onların nə qədər dəqiq olduğunu qiymətləndirmək üçün onun proqnozlarını izləyin. Unutmayın ki, bu, qələbənin qarantiyası deyil, oyun strategiyanızda sizə kömək edəcək bir vasitədir. Aviator Predictor app offer a tempting promise of improved odds and increased winnings, but its effectiveness is questionable, and its use raises ethical and legal concerns. While some players may such apps helpful, it’s important to approach these apps with caution and consider the potential risks involved. Responsible gaming and developing your own strategies may be a more sustainable and enjoyable approach to playing Aviator. 

發佈回覆給「MichaelNeolo」的留言 取消回覆

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *