diff --git a/string_format_test.py b/string_format_test.py new file mode 100644 index 0000000..62ebcb5 --- /dev/null +++ b/string_format_test.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 + +if __name__ == "__main__": + print(f"Price {1:.2f}") + print(f"Price {3.1415:.2f}") + print(f"Price {300000000.1415:,.2f}") + + print(f"Value hex {1000:x}") + print(f"Value hex {1000:X}") + print(f"Value hex {1:.2%}") + + print("Price {0:,.2f}, count {1}".format(100, 100)) + print("Price {price:,.2f}, count {count}".format(price=100, count=100))