.replace()

看程式碼說故事來著:

str = "Hello Andy"

str.replace("Andy", "Lina")

print str

結果:Hello Lina

 

.format()

print( "{} likes {}") .format("Tom", "Sherry")        結果:Tom likes Sherry

print( "{0} likes {1}") .format("Tom", "Sherry")    結果:Tom likes Sherry

print( "{1} likes {0}") .format("Tom", "Sherry")    結果:Sherry likes Tom

 

恩比柿 發表在 痞客邦 PIXNET 留言(0) 人氣()