![](/img/trans.png)
[英]How do you read rows from a csv file and store it in an array using Python codes?
[英]how do you store an array within a new array using python
我正在遍歷數組中存儲的數字列表,如果它們小於10,我想將它們存儲在新數組中。 到目前為止,這是我嘗試過的。
num = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
i []
for index in range(len(num)):
if num[index] < 10:
i = [num[index]]
for index in range(len(i)):
print i[index]
num = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
result = [x for x in num if x<10]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.