Python string formatting symbols

Source: Internet
Author: User
1. String formatting symbols meaning

%c: Formatting characters and their ASCII code

%s: Formatted string

%d: Formatted integer

%o: Formatting unsigned octal numbers

%x: Formatting unsigned hexadecimal numbers

%x: Formatting unsigned hexadecimal number (uppercase)

%F: Format fixed-point number to specify the precision after the decimal point

%e: Formatting fixed-point numbers with scientific notation

%E: function with%E, format fixed-point number with scientific notation

%g: Depending on the size of the value, use%f live%e

%G: function with%G, depending on the size of the value to use%f or%e

2. Formatting operator Auxiliary Instructions

M.n:m is the smallest total width displayed, and n is the number of digits after the decimal point

-: For left alignment

+: Show plus sign (+) before positive number

#: Display ' 0o ' before octal number, ' 0x ' or ' 0X ' before hexadecimal number

0: Display number preceded by ' 0 ' to replace space

Python string formatting symbols

Related Article

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.