python 构造三维全零数组的方法
作者:guotong1988 时间:2022-05-11 06:01:20
如下所示:
temp1 = [[] for i in range(10)]
temp2 = [temp1 for i in range(20)]
temp3 = [temp2 for i in range(30)]
for i in range(30):
for j in range(20):
for k in range(10):
temp3[i][j][k] = 0
但是赋值的时候还是发现是指向同一地址的
所以还得这样
matrix3d=[]
for i in range(30):
matrix3d.append([])
for j in range(20):
matrix3d[i].append([])
for k in range(10):
matrix3d[i][j].append(0)
来源:https://blog.csdn.net/guotong1988/article/details/71173319
标签:python,三维,数组
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python的endswith()的使用方法及实例
2023-04-30 04:42:11
![](https://img.aspxhome.com/file/2023/6/85266_0s.png)
超轻量级MSXML多功能测试程序
2009-05-19 12:38:00
![](https://img.aspxhome.com/file/UploadPic/20095/19/20090513224141384-92s.gif)
python实现的读取网页并分词功能示例
2022-05-08 07:06:38
![](https://img.aspxhome.com/file/2023/3/83683_0s.png)
Python使用穷举法求两个数的最大公约数问题
2022-01-20 21:26:51
![](https://img.aspxhome.com/file/2023/7/90457_0s.png)
在Python中使用NLTK库实现对词干的提取的教程
2022-11-04 15:13:53
![](https://img.aspxhome.com/file/2023/6/67756_0s.jpg)
Python生成器常见问题及解决方案
2023-01-23 19:09:43
用Python的urllib库提交WEB表单
2023-06-11 00:14:52
在 Python 中使用 MQTT的方法
2022-01-26 12:32:48
![](https://img.aspxhome.com/file/2023/5/90515_0s.png)
详解PHP中数组函数的知识点
2023-05-29 10:59:11
![](https://img.aspxhome.com/file/2023/1/55361_0s.png)
Python3环境安装Scrapy爬虫框架过程及常见错误
2021-10-19 00:01:05
Python下利用BeautifulSoup解析HTML的实现
2021-11-20 03:33:54
python如何提取xml指定内容
2021-07-02 01:21:10
![](https://img.aspxhome.com/file/2023/9/68899_0s.png)
Python数据可视化之用Matplotlib绘制常用图形
2023-04-05 07:10:46
![](https://img.aspxhome.com/file/2023/7/101157_0s.png)
Python实现的生产者、消费者问题完整实例
2022-08-15 14:37:30
Python 实现网页自动截图的示例讲解
2023-10-23 09:48:48
![](https://img.aspxhome.com/file/2023/6/112576_0s.jpg)
Python如何配置环境变量详解
2021-11-20 08:18:21
![](https://img.aspxhome.com/file/2023/6/97056_0s.png)
python中 @的含义以及基本使用方法
2022-12-24 04:58:48
python3获取控制台输入的数据的具体实例
2022-05-08 13:49:37
![](https://img.aspxhome.com/file/2023/6/118726_0s.png)
PythonPC客户端自动化实现原理(pywinauto)
2022-11-27 02:24:27
![](https://img.aspxhome.com/file/2023/3/95673_0s.png)
IE6终极备忘单——策略
2010-01-13 13:05:00