2006年02月23日 星期四 16:08
看到 使用 `` 把数字转化为字符串 ( ` 是键盘左上角的那个字符,不知道怎么称呼?) >>> import time >>> time.time() 1140682077.5150001 >>> str(time.time()) '1140682085.03' >>> `time.time()` '1140682091.4679999' >>> type(`time.time()`)这种用法在哪里可以查到说明? -- http://my.opera.com/zhangyunfeng
2006年02月23日 星期四 16:13
repr函数用来取得对象的规范字符串表示。反引号(也称转换符)可以完成相同的功能。注意,在大多数时候有eval(repr(object)) ==
object。
>>> i = []
>>> i.append('item')
>>> `i`
"['item']"
>>> repr(i)
"['item']"
基本上,repr函数和反引号用来获取对象的可打印的表示形式。你可以通过定义类的__repr__方法来控制你的对象在被repr函数调用的时候返回的内容。
在06-2-23,zhang yunfeng <zhangyunfeng at gmail.com> 写道:
>
> 看到 使用 `` 把数字转化为字符串 ( ` 是键盘左上角的那个字符,不知道怎么称呼?)
>
> >>> import time
> >>> time.time()
> 1140682077.5150001
> >>> str(time.time())
> '1140682085.03'
> >>> `time.time()`
> '1140682091.4679999'
> >>> type(`time.time()`)
>
>
>
> 这种用法在哪里可以查到说明?
>
>
> --
> http://my.opera.com/zhangyunfeng
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060223/c9a31cfb/attachment.html
Zeuux © 2025
京ICP备05028076号