1、 源碼及輸出
list=input()
b=list.split(" ")
print(b) #這裡b已經是個list
a=map(int,b)
print(a) #map後傳回的是個位址
print(list(a)) #這一句報錯
12 34 56 67
Traceback (most recent call last):
File "D:/爬蟲/chengdu/LianJia/練習.py", line 23, in <module>
print(list(a))
TypeError: 'str' object is not callable
['12', '34', '56', '67']
<map object at 0x00000000026FE550>
2、
score=list(map(int,input().split()))
print(score)
傳回值:
1 2 3 4 5
[1, 2, 3, 4, 5] #傳回值為list
score=map(int,input().split())
print(score)
傳回值:
1 2 3 4 5
<map object at 0x00000000026FE550> #結果為記憶體位址