嗨,我想生成从 1000000 到 2000000 的数字列表,但问题是我得到一个错误内存错误我使用的是随机的一切都很好,只有我得到重复的数字,我不能有重复的数字,所以我切换到 xrange
data = []
total = 2000000
def resource_file(info):
with open(info, "r") as data_file:
reader = csv_reader(data_file, delimiter=",")
for row in reader:
try:
for i in xrange(1000000,total):
new_row = [row[0], row[1], i]
data.append(new_row)
except IndexError as error:
print(error)
with open(work_dir + "new_data.csv", "w") as new_data:
writer = csv_writer(new_data, delimiter=",")
for new_row in data:
writer.writerow(new_row)