xrange与range的区别

xrange属于类,继承自object.
用法:
xrange(stop) -> xrange object
xrange(start, stop[, step]) -> xrange object

range属于函数,返回list,而xrange返回xrange object.对于循环而言,稍快于range(),内存效率更高.
#!/usr/bin/python
# -*- coding: UTF- -*-
n =
for c in xrange(n):
    print c
 format()  格式化输出字符串,format(value, format_spec)实质上是调用了value的__format__(format_spec)方法

"I am {0}, I like {1}!".format("wang", "moon")
'I am wang, I like moon!'
上一篇:【目录】Matlab和C#混合编程文章目录


下一篇:总结asp.net页面跳转