Created
April 4, 2020 13:09
-
-
Save vmorris/0ca0b55e006e9ac835964b1689e22e71 to your computer and use it in GitHub Desktop.
python string formatting 101
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> def log(msg, *args): | |
... if args: | |
... msg %= args | |
... print(msg) | |
... | |
>>> log('hi') | |
hi | |
>>> log('hi %s', 'mom') | |
hi mom | |
>>> log('testing %s %s %s', 1, 2, 3) | |
testing 1 2 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment