repr

>>> import datetime

>>> today=datetime.datetime.now()

>>> today
datetime.datetime(2015, 10, 12, 20, 33, 19, 634000)

>>> type(today)
<type 'datetime.datetime'>
>>> #type(today)这是一个时间类型的数据

>>> str(today)
'2015-10-12 20:33:19.634000'

>>> type(str(today))
<type 'str'>

>>> repr(today)#将时间类型的对象转化为可打印的字符串,原对象不做任何的改变
'datetime.datetime(2015, 10, 12, 20, 33, 19, 634000)'

>>> type(repr(today))
<type 'str'>

>>> eval(repr(today))
datetime.datetime(2015, 10, 12, 20, 33, 19, 634000)
>>> 

 

posted @ 2015-10-12 20:35  Xiao|Deng  阅读(212)  评论(0编辑  收藏  举报