>>> eval(str([1, 2, 3]))
[1, 2, 3]
13
4.1.1 字符串格式化
使用format方法进行格式化
>>> print("The number {0:,} in hex is: {0:#x}, the number {1} in oct is {1:#o}".format(5555,55))
11
4.1.1 字符串格式化
>>> x = 1235
>>> so = "%o" % x
>>> so
"2323"
>>> sh = "%x" % x
>>> sh
"4d3"
>>> se = "%e" % x
>>> se
"1.235000e+03"
>>> chr(ord("3")+1)
"4"
>>> "%s" % 65
>>> s.rpartition('banana')
('apple,peach,', 'banana', ',pear')
'[1, 2, 3]'
>>> str((1,2,3))
#直接把对象转换成字符串
'(1, 2, 3)'