要用Python存储25M的3-元组,可以使用以下方法:
import pickle
data = (1, 2, 3)
with open('data.pkl', 'wb') as f:
pickle.dump(data, f)
with open('data.pkl', 'rb') as f:
loaded_data = pickle.load(f)
import numpy as np
data = (1, 2, 3)
np.save('data.npy', data)
loaded_data = np.load('data.npy')
import sqlite3
data = (1, 2, 3)
conn = sqlite3.connect('data.db')
cursor = conn.cursor()
cursor.execute('CREATE TABLE IF NOT EXISTS my_table (data BLOB)')
cursor.execute('INSERT INTO my_table VALUES (?)', (data,))
conn.commit()
cursor.execute('SELECT * FROM my_table')
loaded_data = cursor.fetchone()[0]
cursor.close()
conn.close()
这些方法都可以用来存储25M的3-元组,具体选择哪种方法取决于你的需求和使用场景。
领取专属 10元无门槛券
手把手带您无忧上云