MATLAB 的冒号运算符的 Python 等效项 [英] Python Equivalent of MATLAB's colon operator
本文介绍了MATLAB 的冒号运算符的 Python 等效项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 MATLAB 中,我可以使用 :
、冒号、运算符创建单调间隔的向量,如下例所示.如何在 Python 中以同样简洁的方式执行此操作?
In MATLAB I can create monotonically spaced vectors as in the examples below using the :
, colon, operator. How can I do this in Python in a similarly concise manner?
>> x=1:10
x =
1 2 3 4 5 6 7 8 9 10
或
>> x=0:2:10
x =
0 2 4 6 8 10
推荐答案
有范围
range([start], stop[, step])
[]
显示可选参数.默认范围从零开始
[]
shows optional arguments. Default ranges starts with zero
这篇关于MATLAB 的冒号运算符的 Python 等效项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文