1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-07-30 19:40:36 +02:00

Mention that Python 2.5-style string formatting still works in 3

This commit is contained in:
Adam Brenecki
2014-07-16 10:25:03 +09:30
parent 0654a19b44
commit 164cf1ce78

View File

@@ -98,6 +98,10 @@ not False # => True
# You can use keywords if you don't want to count.
"{name} wants to eat {food}".format(name="Bob", food="lasagna") #=> "Bob wants to eat lasagna"
# If your Python 3 code also needs to run on Python 2.5 and below, you can also
# still use the old style of formatting:
"%s can be %s the %s way" % ("strings", "interpolated", "old")
# None is an object
None # => None