xrange属于类,继承自object. 用法: xrange(stop) -> xrange object xrange(start, stop[, step]) -> xrange object range属于函数,返回list,而xrange返回xrange object.对于循环而言,稍快于range(),内存效率更高.
#!/usr/bin/python # -*- coding: UTF-8 -*- n = 10 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!‘
原文地址:https://www.cnblogs.com/guxuanqing/p/9404511.html
时间: 2024-10-08 08:37:23