From 43147922c5ace7b2a4a980db3a7c084861d3c5ec Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Sat, 6 Sep 2025 23:19:36 +0800 Subject: [PATCH] feat: add string_format_test.py --- string_format_test.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 string_format_test.py 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))