Python sixth day (string conversion)

Source: Internet
Author: User

Python string conversion


The Int function converts a string to a number

The STR function converts a number to a string

>>> int (' 100 ')

100

>>> STR (100)

' 100 '

The REPR function can convert an object to a different string form, and then the returned

Object will be a string of code


Built-in functions can convert floating-point numbers to strings

or convert the string to a floating-point number


>>> STR (1.1)

' 1.1 '

>>> float (' 1.1 ')

1.1000000000000001



String Code Conversions

The Ord function can convert a single character to ASCII

The CHR function can convert ASCII to the corresponding character

>>> Ord (' W ')

119

>>> Chr (119)

' W '


This article is from the "Don't Ang" blog, please be sure to keep this source http://wuang.blog.51cto.com/9559762/1606445

Python sixth day (string conversion)

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.