python之函数用法xrange()
# -*- coding: utf-8 -*-
#python 27
#xiaodeng
#python之函数用法xrange() #xrange()
#说明:返回一个生成器
#xrange做循环的性能比range好,尤其是返回很大的时候.除非要返回一个列表,则用range.
'''
class xrange(object)
| xrange(stop) -> xrange object
| xrange(start, stop[, step]) -> xrange object
|
| Like range(), but instead of returning a list, returns an object that
| generates the numbers in the range on demand. For looping, this is
| slightly faster than range() and more memory efficient.
''' #案例
x= xrange(5) #xrange(5)-> xrange对象
print list(x) #[0, 1, 2, 3, 4]
python之函数用法xrange()的更多相关文章
- Python回调函数用法实例详解
本文实例讲述了Python回调函数用法.分享给大家供大家参考.具体分析如下: 一.百度百科上对回调函数的解释: 回调函数就是一个通过函数指针调用的函数.如果你把函数的指针(地址)作为参数传递给另一个函 ...
- python之函数用法setdefault()
# -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法setdefault() #D.get(k,d) #说明:k在D中,则返回 D[K], ...
- python之函数用法fromkeys()
# -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法fromkeys() #fromkeys() #说明:用于创建一个新字典,以序列seq ...
- python之函数用法get()
# -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法get() #http://www.runoob.com/python/att-dic ...
- python之函数用法capitalize()
# -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法capitalize() #capitalize() #说明:将字符串的第一个字母变成 ...
- python之函数用法isupper()
# -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法isupper() #http://www.runoob.com/python/att ...
- python之函数用法islower()
# -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法islower() #http://www.runoob.com/python/att ...
- python之函数用法startswith()
# -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法startswith() #http://www.runoob.com/python/ ...
- python之函数用法endswith()
# -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法endswith() #http://www.runoob.com/python/at ...
随机推荐
- WIN8.1 IE11 F12开发者人员工具,开启什么都不显示
WIN8.1 IE11 F12开发者人员工具,开启什么都不显示,求大神帮忙? IE11也没法重装, 还原IE设置过了. 没有效果. 也试过把IE停掉,重启后再重新打开 也没用 已经解决了 删除 ...
- static关键字与方法区和类加载
1.static的作用 答:将成员变量或方法存储进方法区.因为方法区能保证数据只存在一份,只会加载一次(类加载器加载类的时候才加载一次) 注:static Object obj = new Objec ...
- java异常知识点汇总
异常处理方法 对于非运行时异常(checked exception),必须要对其进行处理,否则无法通过编译. 处理方式有两种: 1.使用try..catch..finally进行捕获: 2.在产生异常 ...
- 【docker】docker容器和宿主机之间文件互传,互相拷贝
原文地址:https://www.cnblogs.com/areyouready/p/8973495.html [注意:命令中符号均为英文符号] 1.从容器里面拷文件到宿主机 答:在宿主机里面执行以下 ...
- ubuntu下C++和C编程
一.anjuta Anjuta DevStudio 的官方地址:http://anjuta.sourceforge.net/Anjuta是一个C/C++ IDE,它最大的特色是灵活,同时打开多个文 ...
- struts2 select标签
headerValue : 默认值value headerKey : 默认name list : 源数据 (可以在action方法里从数据库获取list) name : 被选数据存放的位置(这里我方在 ...
- react random key generator;react如何产生随机不重复的key
1.<div key={+new Date() + Math.random()}> 2.使用数组的索引 3.使用uuid:https://www.npmjs.com/package/uui ...
- 如何获取隔壁wifi密码,非暴力破解
目前常见的Wi-Fi加密方式有WEP.WPA2和WPS(链接为各自的破解方式),不过有网友反映以往破解WPA2的方法耗时太长,而且不适用于所有WPS启动的接入点.而今天介绍的这种方法则更加省时省力. ...
- Search a 2D Matrix leetcode java
题目: Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the f ...
- android中一些特殊字符(如:←↑→↓等箭头符号)的Unicode码值
在项目中,有时候在一些控件(如Button.TextView)中要添加一些符号,如下图所示: 这个时候可以使用图片的方式来显示,不过这些可以直接使用U ...