你是怎么做数组的 [英] How do you do arrays
问题描述
我是Pyton的新人,我从书中学习而不是上课
所以请原谅我的行动很慢
以下不起作用我得到了一个文件错误
" Matrix [index] = k
NameError:name''iMatrix''未定义"
而索引< majorlop1:
index = index + 1
k = random.choice(listvalues)+ 1
iMatrix [index] = k
数组的书籍声明(typecode,初始化程序)对我来说没有任何意义
它是如何将组织名称的俄罗斯联盟遗忘的br />
数组。
谢谢
Tom
I am new at Pyton and I am learning from book not classes
so please forgive my being slow
The below does not work I get an Error of File
"Matrix[index] = k
NameError: name ''iMatrix'' is not defined"
while index < majorlop1:
index = index + 1
k = random.choice(listvalues) + 1
iMatrix[index] = k
The book statement of
array(typecode, initializer) does not make sence
to me how it henerates ore relaes to the org name
for the array.
Thank You
Tom
推荐答案
Tom,
在使用iMatrix [index]之前,你必须告诉python使用iMatrix
作为数组。你将使用iMatrix = [] *在循环之外。
iMatrix = []
而索引< majorlop1:#其余的循环语句
既然你是新手,请看一下Python教程给你
开始。
http://docs.python.org/tut/tut.html
谢谢,
-Kartic
Tom,
Before you use iMatrix[index], you have to tell python to use iMatrix
as an array. You will do that using iMatrix = [] *outside* the loop.
iMatrix = []
while index < majorlop1: # rest of the loop statements
Since you are new, please take a look at the Python tutorial to get you
started.
http://docs.python.org/tut/tut.html
Thanks,
-Kartic
,它被称为 ;列表与QUOT;用Python的说法。
and it is called a "List" in Python parlance.
2005年2月1日星期二10:52:45 -0800,Thomas Bunce< tb **** @ mac.com> ;写道:
On Tue, 01 Feb 2005 10:52:45 -0800, Thomas Bunce <tb****@mac.com> wrote:
我是Pyton的新手,我正在从书中学习而不是上课
所以请原谅我慢慢来
以下不起作用我得到一个错误of File
" Matrix [index] = k
NameError:name''iMatrix''未定义"
而index< majorlop1:
index = index + 1
k = random.choice(listvalues)+ 1
iMatrix [index] = k
书的声明
数组(typecode,初始化程序)对我来说如何为阵列的组织名称
留下了重要的东西。
谢谢你汤姆
-
http://mail.python .org / mailman / listinfo / python-list
I am new at Pyton and I am learning from book not classes
so please forgive my being slow
The below does not work I get an Error of File
"Matrix[index] = k
NameError: name ''iMatrix'' is not defined"
while index < majorlop1:
index = index + 1
k = random.choice(listvalues) + 1
iMatrix[index] = k
The book statement of
array(typecode, initializer) does not make sence
to me how it henerates ore relaes to the org name
for the array.
Thank You
Tom
--
http://mail.python.org/mailman/listinfo/python-list
与任何其他变量一样,您需要在使用之前声明iMatrix:
Like any other variable, you need to declare iMatrix before you use it:
这篇关于你是怎么做数组的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!