words = claim.split()
words
>>>['Pluto','is','a','planet!']
datestr ='1956-01-31'
year, month, day = datestr.split('-')
/'.join([month, day, year])>>>'01/31/1956'
' 👏 '.join([word.upper()for word in words])>>>'PLUTO 👏 IS 👏 A 👏 PLANET!'
planet +', we miss you.'>>>'Pluto, we miss you.'
position =9
planet +", you'll always be the "+str(position)+"th planet to me.">>>"Pluto, you'll always be the 9th planet to me."
.format()的一些用法
# We call .format() on a "format string", where the Python values we want to insert are represented with {} placeholders."{}, you'll always be the {}th planet to me.".format(planet, position)>>>"Pluto, you'll always be the 9th planet to me."
pluto_mass =1.303*10**22
earth_mass =5.9722*10**24
population =52910390# 2 decimal points 3 decimal points, format as percent separate with commas"{} weighs about {:.2} kilograms ({:.3%} of Earth's mass). It is home to {:,} Plutonians.".format(
planet, pluto_mass, pluto_mass / earth_mass, population,)>>>"Pluto weighs about 1.3e+22 kilograms (0.218% of Earth's mass). It is home to 52,910,390 Plutonians."
s ="""Pluto's a {0}.
No, it's a {1}.
{0}!
{1}!""".format('planet','dwarf planet')print(s)>>>Pluto's a planet.
No, it's a dwarf planet.
planet!
dwarf planet!