Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
66b25ef0
Commit
66b25ef0
authored
Feb 10, 2018
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add examples
parent
6cb68f94
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
7 deletions
+10
-7
doc/syntax.rst
doc/syntax.rst
+10
-7
No files found.
doc/syntax.rst
View file @
66b25ef0
...
@@ -336,6 +336,16 @@ Aligning the text and specifying a width::
...
@@ -336,6 +336,16 @@ Aligning the text and specifying a width::
format("{:*^30}", "centered"); // use '*' as a fill char
format("{:*^30}", "centered"); // use '*' as a fill char
// Result: "***********centered***********"
// Result: "***********centered***********"
Dynamic width::
format("{:<{}}", "left aligned", 30);
// Result: "left aligned "
Dynamic precision::
format("{:.{}f}", 3.14, 1);
// Result: "3.1"
Replacing ``%+f``, ``%-f``, and ``% f`` and specifying a sign::
Replacing ``%+f``, ``%-f``, and ``% f`` and specifying a sign::
format("{:+f}; {:+f}", 3.14, -3.14); // show it always
format("{:+f}; {:+f}", 3.14, -3.14); // show it always
...
@@ -360,13 +370,6 @@ Replacing ``%x`` and ``%o`` and converting the value to different bases::
...
@@ -360,13 +370,6 @@ Replacing ``%x`` and ``%o`` and converting the value to different bases::
format("{:,}", 1234567890);
format("{:,}", 1234567890);
'1,234,567,890'
'1,234,567,890'
Expressing a percentage::
>>> points = 19
>>> total = 22
Format("Correct answers: {:.2%}") << points/total)
'Correct answers: 86.36%'
Using type-specific formatting::
Using type-specific formatting::
>>> import datetime
>>> import datetime
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment