str和repr区别
str函数,它会把值转换为合理形式的字符串,以便用户可以理解。
repr会创建一个字符串,它以合法的Python表达式的形式来表示值。
例如:
>>> print repr("hello, world!")'hello, world!'>>> print repr(1000L)1000L>>> print str("hello, wolrd!")hello, wolrd!>>> print str(1000L)1000>>> temp = 42L>>> print "The temperature is " + `temp`The temperature is 42L>>>