(1)range() 和 xrange( )【python内置函数】

range(开始,结束,间隔)。

值得注意的是:生成数列最后一个数< 结束值。

返回结果类型:list,其中元素是integer类型。(说明 python2中range()返回的是list,python3中range返回的是<range>类对象,需要用list()函数转成list,如 list(range(...)) )

如:

备注说明: python 3 把 xrange( )去掉了

(2) numpy.linspace() 【numpy库文件中的函数】

numpy.linspace(开始,结束,个数(默认50))

返回结果类型:ndarray,其中元素是float类型。如:


【references】

[1] https://docs.scipy.org/doc/numpy/reference/generated/numpy.linspace.html

numpy.linspace(startstopnum=50endpoint=Trueretstep=Falsedtype=None)[source]

Return evenly spaced numbers over a specified interval.

Returns num evenly spaced samples, calculated over the interval [startstop].

The endpoint of the interval can optionally be excluded.

Parameters:

start : scalar

The starting value of the sequence.

stop : scalar

The end value of the sequence, unless endpoint is set to False. In that case, the sequence consists of all but the last of num + 1 evenly spaced samples, so that stop is excluded. Note that the step size changes when endpoint is False.

num : int, optional

Number of samples to generate. Default is 50. Must be non-negative.

endpoint : bool, optional

If True, stop is the last sample. Otherwise, it is not included. Default is True.

retstep : bool, optional

If True, return (samplesstep), where step is the spacing between samples.

dtype : dtype, optional

The type of the output array. If dtype is not given, infer the data type from the other input arguments.

New in version 1.9.0.

Returns:

samples : ndarray

There are num equally spaced samples in the closed interval [start, stop] or the half-open interval [start, stop) (depending on whether endpoint is True or False).

step : float, optional

Only returned if retstep is True

Size of spacing between samples.

python 生成特定间隔数列的方法的更多相关文章

  1. 使用Python生成源文件的两种方法

    利用Python的字符串处理模块,开发者能够编写脚本用来生成那些格式同样的C.C++.JAVA源程序.头文件和測试文件,从而避免大量的反复工作. 本文概述两种利用Python string类生成jav ...

  2. [ Python入门教程 ] Python生成随机数模块(random)使用方法

    1.使用randint(a,b)生成指定范围内的随机整数.randint(a,b)表示从序列range([a,b])中获取一个随机数,包括b. >>> random.randint( ...

  3. python 生成随机数的几种方法

      随机取一个: import random random.choice(string.digits)#从数字里随机选取一位数字: 随机取多位数:   random.sample(string.dig ...

  4. Python生成随机数的方法

    这篇文章主要介绍了Python生成随机数的方法,有需要的朋友可以参考一下 如果你对在Python生成随机数与random模块中最常用的几个函数的关系与不懂之处,下面的文章就是对Python生成随机数与 ...

  5. python快速生成注释文档的方法

    python快速生成注释文档的方法 今天将告诉大家一个简单平时只要注意的小细节,就可以轻松生成注释文档,也可以检查我们写的类方法引用名称是否重复有问题等.一看别人专业的大牛们写的文档多牛多羡慕,不用担 ...

  6. 【python】【转】Python生成随机数的方法

    如果你对在Python生成随机数与random模块中最常用的几个函数的关系与不懂之处,下面的文章就是对Python生成随机数与random模块中最常用的几个函数的关系,希望你会有所收获,以下就是这篇文 ...

  7. Python生成随机数组的方法小结

    Python生成随机数组的方法小结 本文实例讲述了Python生成随机数组的方法.分享给大家供大家参考,具体如下: 研究排序问题的时候常常需要生成随机数组来验证自己排序算法的正确性和性能,今天把Pyt ...

  8. python实现基于两张图片生成圆角图标效果的方法

    python实现基于两张图片生成圆角图标效果的方法 这篇文章主要介绍了python实现基于两张图片生成圆角图标效果的方法,实例分析了Python使用pil模块进行图片处理的技巧,分享给大家供大家参考. ...

  9. random and password 在Linux下生成crypt加密密码的方法,shell 生成指定范围随机数与随机字符串

    openssl rand -hex n (n is number of characters) LANG=c < /dev/urandom tr -dc _A-Z-a-z-0-9 | head ...

随机推荐

  1. 【C/C++】高亮C++中函数的重写——函数名相同?参数列表相同?返回值相同?

    C++的重载给人留下了非常深刻的影响,原因是重载的条件很值得注意:函数名相同,参数列表不相同的两个函数构成重载函数,而无关乎二者的返回值. 但是C++中的函数重写又是另一码事.标准规定:只要函数名相同 ...

  2. 深入Asyncio(一)入门介绍

    介绍 Asyncio试图解决什么问题? 对于IO负载,有且仅有两个理由使用基于asyncio的并发而不是基于多线程的并发: 1. Asyncio为抢占式多任务(线程)提供了一个更安全的替代方案,避免了 ...

  3. 17 nginx连接memcached

    一:配置php扩展memcached wget http://memcached.googlecode.com/files/memcached-1.4.9.tar.gz # tar zvxf memc ...

  4. WPF converter(包含传递复杂参数)

    单值转换器 将单一值转换为特定类型的值,以日期转换为例如下: 1.定制DateConverter类,其中当值从绑定源传播给绑定目标时,调用方法Convert. 1 public class DateC ...

  5. alibaba canal安装笔记

    canal是alibaba开源的基于mysql binlog解析工具,可利用它实现mysql增量订阅/消费,典型的应用场景如下图: 利用canal,可以将mysql的数据变化,通过解析binlog,投 ...

  6. iOSPOI检索详细总结

    iOS百度地图路径规划和POI检索详细总结 路径规划.png 百度地图的使用 百度地图API的导入网上说了许多坑,不过我遇到的比较少,这里就放两个比较常见的吧.坑一: 奥联WIFI_xcodeproj ...

  7. linux 打印系统时间操作

    版权为个人所有,如需转载请说明出处.(东北大亨) http://www.cnblogs.com/northeastTycoon/p/5511498.html 1. 打开shell脚本 例子1:输出两天 ...

  8. java项目中的classpath到底是什么

    https://segmentfault.com/a/1190000015802324

  9. Webpack探索【16】--- 懒加载构建原理详解(模块如何被组建&如何加载)&源码解读

    本文主要说明Webpack懒加载构建和加载的原理,对构建后的源码进行分析. 一 说明 本文以一个简单的示例,通过对构建好的bundle.js源码进行分析,说明Webpack懒加载构建原理. 本文使用的 ...

  10. 各种python 函数參数定义和解析

    python 中的函数參数是赋值式的传递的,函数的使用中要注意两个方面:1.函数參数的定义过程,2.函数參数在调用过程中是怎样解析的. 首先说一下在python 中的函数调用过程是分四种方式的.这里且 ...