Neaten-up examples.

This commit is contained in:
Raymond Hettinger 2009-03-12 22:36:03 +00:00
parent fd412e16c5
commit b0b34d7ed5
1 changed files with 3 additions and 4 deletions

View File

@ -82,9 +82,8 @@ defaults to three.
The type specifier approach is locale aware. The picture formatting only
offers a COMMA as a thousands separator::
String.Format("{0:c}", 12400) ==> "$12,400"
String.Format("{0:n}", 12400) ==> "12,400"
String.Format("{0:0,0}", 12400) ==> "12,400"
String.Format("{0:n}", 12400) ==> "12,400"
String.Format("{0:0,0}", 12400) ==> "12,400"
.. _`C-Sharp`: http://blog.stevex.net/index.php/string-formatting-in-csharp/
@ -106,7 +105,7 @@ The proposal works well with floats, ints, and decimals.
It also allows easy substitution for other separators.
For example::
format(n, "6,f").replace(",", "_")
format(n, "6,d").replace(",", "_")
This technique is completely general but it is awkward in the
one case where the commas and periods need to be swapped::