将列表初始化为Python中已知数量的元素[duplicate](Initializing a list to a known number of elements in Python [duplic

编程入门 行业动态 更新时间:2024-10-28 12:28:31
将列表初始化为Python中已知数量的元素[duplicate](Initializing a list to a known number of elements in Python [duplicate])

这个问题已经在这里有一个答案:

在一定大小的 6个答案的 python中创建一个空列表

现在我正在使用一个列表,期待着像:

verts = list (1000)

我应该使用数组吗?

This question already has an answer here:

Create an empty list in python with certain size 14 answers

Right now I am using a list, and was expecting something like:

verts = list (1000)

Should I use array instead?

最满意答案

我想到的第一件事是:

verts = [None]*1000

但是你真的需要预先初始化它吗?

The first thing that comes to mind for me is:

verts = [None]*1000

But do you really need to preinitialize it?

更多推荐

本文发布于:2023-08-01 16:34:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1362807.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:元素   数量   列表   Python   duplicate

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!