以下用 C 编写的代码在 Python 中的等效项是什么?
int a[100];
int lim;
scanf("%d",&lim)
for(i=0;i<lim;i++)
scanf("%d",&a[i]);
最佳答案
这里
# create an empty list
a = [];
# take limt as input
lim = raw_input("Enter limit")
# this is python style of for loop
# here i will start from 0 and will go upto limit
for i in range (0, int(lim)):
# take input from user one by one and append to list
elem = raw_input("")
a.append(int(elem))
关于c - 如何在 Python 列表中动态插入数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23925042/