七十二、str类
1、定义:
class str(basestring) | str(object='') -> string | | Return a nice string representation of the object. | If the argument is a string, the return value is the same object. | | Method resolution order: | str | basestring | object
2、解释:返回一个对象的string表现方式
3、举例:
>>> str(1) '1' >>> str(u"fdsa") 'fdsa' >>> import datetime >>> str(datetime.datetime.now()) '2016-07-03 18:29:41.422000'
七十三、sum方法
1、定义:
sum(...) sum(sequence[, start]) -> value Return the sum of a sequence of numbers (NOT strings) plus the value of parameter 'start' (which defaults to 0). When the sequence is empty, return start.
2、解释:返回一个数字序列与start变量总和
3、举例:
>>> sum(range(5))
10
>>> sum(range(5),3)
13
Copyright © 2021.aoyanming个人博客站
发表评论