import numpy as np
a = (['a','b','c',],['d','e','f','g'],['h','i','j','k'])
for row in a:
print row
for i in range(0,4):
for j in range(0,4):
print a[i][j]
我想在n!=m
打印一个数组。我上面的代码我收到以下错误。
Traceback (most recent call last):
File "/Users/pankajsehgal/mystuff/Python_Practise/2darray", line 10, in <module>
print a[i][j]
IndexError: list index out of range
我知道它超出范围,有没有办法打印它。没有使用numpy。
答案 0 :(得分:1)
intValue
或者只是:
import numpy as np
a = (['a','b','c',],['d','e','f','g'],['h','i','j','k'])
for row in a:
print row
for i in range(len(a)):
sublistlen = len(a[i])
for j in range(0,sublistlen):
print a[i][j]