标签: python list python-3.x range
根据list from range
以下内容应该有效:
x = list(range(0, 10, 100)) print(x)
但它会打印[0],而我期待[0,0.01,...,10]我缺少什么?
[0]
[0,0.01,...,10]
答案 0 :(得分:2)
range不做分数。第三个参数是步骤,即:
range
range(start, stop, step)
要获得您想要的分数,您可以使用numpy数组。例如:
numpy
import numpy as np x = np.linspace(0, 10, 100)