Python basic data preprocessing syntax function (2)

Source: Internet
Author: User

String formatting methods use of format:

<^>#left-aligned, centered, right- aligned, respectively'{: >18,.2f}'. Format (70305084.0)#: Colon + blank padding + right-aligned + fixed-width 18 + floating-point precision. The declaration of floating-point number f'{: ^10}'. Format ('Test')#return test centered, 10 characters total'{1} {0}'. Format (' One',' Both')#the numbers in {} represent the order of the permutations'My name is {Name},age are {age}'. Format (name='HoHo', age=19) '{0:*>10}'. Format (10)#Align Right'{0:*<10}'. Format (10)##左对齐 with a colon followed by a * as the fill
b_dict = {' name ': ' Chuhao ', ' Age ': ' Province ': ' Shanxi '}
Print (' My name is {name} ' and ' age ' {age},from {province} '. Format (**b_dict)) #通过字典来对句子进行填充

Python basic data preprocessing syntax function (2)

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.