Python basic data Type-string

Source: Internet
Author: User

Format Print

1)%s: Represents a String

2)%d: Represents an integer

3)%f: Represents floating point number


1. Format Printing 1

Name = "Xiaoming" age = 29job = "IT" Print ("I am%s,age:%d,job:%s"% (name,age,job))

2. Format Printing 2

msg = ' Information of%s ' name:%s Age:%d job:%s '% (name,name,age,job) print (msg)

3. Remove the Blanks

Strip (...) method of Builtins.str instance S.strip ([chars]), str Return a copy of the string S with leading    and trailing whitespace removed. # Remove the opening and trailing spaces of the string If chars is given and not None, remove characters in chars instead. Instance: name = "Xiaoming" age = 29job = "IT" name = Name.strip () print ("I am%s,age:%d,job:%s"% (name,age,job))






This article is from the "guoxianqi2016" blog, make sure to keep this source http://guoxianqi2016.blog.51cto.com/11407620/1762197

Python basic data type-string

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.