string formatting of Python

Source: Internet
Author: User

The Python string supports a simple but powerful output format that formats the output string in several ways:

1, the specified number of decimal digits for the floating-point value

2, using exponential (scientific) notation to represent floating-point numbers

3, align the decimal point of a column of numbers

4, make the output right or left justified

5, inserts a character or string at the specified position in a line of output

6, display all types of data with fixed field width and precision

Conversion indicator Symbol Meaning
C A single character (that is, a string of length 1), or an integer representation of an ASCII character
S String, or a value to convert to a string
D A value with a signed (positive negative number)
U unsigned decimal integers
O unsigned octal integer
X unsigned hexadecimal integers (digits A through F are taken in lowercase)
X unsigned hexadecimal integers (digits A through F are taken in lowercase)
F Floating point number
E,e Floating-point numbers (using scientific notation)
G,g Floating-point number (with the lowest bit significant digits)

end!

string formatting of Python

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.