当我尝试打印matrix1时,输出是对象的内存地址。
print("enter n for nxn matrix")
n = int(input())
matrix1 = []
matrix2 = []
#taking elements of first matrix
print("Enter elements of first matrix")
for i in range(0,n):
#taking elements of first column
print("Enter elements of ",i,"column, seperated by space")
#raw_input().split() will split the string
#'1 2 34'.split() will give ['1', '2', '34']
#map will convert its elements into integers [1, 2, 34]
matrix1.append(map(int,input().split()))
print("Matrix 1 is",matrix1)
print(matrix1)
收到运气。
enter n for nxn matrix
2
Enter elements of first matrix
Enter elements of 0 column, seperated by space
2 3
Enter elements of 1 column, seperated by space
4 5
Matrix 1 is [<map object at 0x101834898>, <map object at 0x1032d2f60>]
不确定为什么要打印对象的内存地址。我正在使用python3。
答案 0 :(得分:0)
0x909090909090
返回自身(或者也许最好说它返回该类型的对象?),但是您仍然可以遍历它:
map
礼物:
j = [1, 2, 3, 4]
j = map(lambda x: x+1, j)
{x for x in j}