1. 使用嵌套列表(Nested Lists):
```python
my_list = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]
2. 使用CSV文件格式:
```python
读取CSV文件
with open('data.csv', 'r') as file:
lines = file.readlines()
data = [line.strip().split(',') for line in lines]
写入CSV文件
with open('data.csv', 'w') as file:
for row in data:
file.write(','.join(row) + '\n')
3. 使用NumPy库:
```python
import numpy as np
创建一个3x3的二维数组
my_array = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
4. 使用Pandas库:
```python
import pandas as pd
创建一个3x3的二维数据框
my_dataframe = pd.DataFrame({
'A': [1, 4, 7],
'B': [2, 5, 8],
'C': [3, 6, 9]
})
以上是Python中存储二维数据的一些常见方法。您可以根据具体需求选择合适的方法