1. 程式人生 > >Python 之 str 、 repr 、 反引號(``)的區別

Python 之 str 、 repr 、 反引號(``)的區別

rep lock 的區別 num str code 轉換 repr 字符

str 、 repr 、 `` 、是將Python值轉換為字符串的3種方式

>> print str("Hello, World !")
hello, world !

>>print repr("Hello, World !")
‘Hello, World !‘

>> temp = 2
>> print "The number is " + temp
The number is 2

Python 之 str 、 repr 、 反引號(``)的區別