Python built-in functions (Ten)--CHR

Source: Internet
Author: User
Tags ord

English documents:

CHR ( i
Return The string representing a character whose Unicode code point is the integer i . For example, CHR ($) returns the string ' a ' , while CHR (8364) returns the string ' € ' . This is the inverse of ord () .
The valid range for the argument are from 0 through 1,114,111 (0x10ffff in base 16). valueerror 'll be raised if I was outside that range
Description:
1. function returns the string representation of the Unicode character corresponding to the value of the Shaping parameter
>>> chr (97)#parameter type is an integer'a'>>> Chr (' the')#argument passed in string times wrongTraceback (most recent): File"<pyshell#6>", Line 1,inch<module>Chr (' the') Typeerror:an integer isrequired (got type str)>>> Type (CHR (97))#The return type is a string<class 'Str'>

2. Its function is exactly the opposite of the Ord function.

>>> chr'a'>>> ord ('a') 97

3. The range of parameter values passed in must be between 0-1114111 (16 binary 0x10ffff), otherwiseValueError错误

>>> chr (-1)#less than 0 errorTraceback (most recent): File"<pyshell#10>", Line 1,inch<module>Chr (-1) VALUEERROR:CHR () Arg not inchRange (0x110000)>>> Chr (1114111)'\u0010ffff'>>> chr (1114112)#over 1114111 errorsTraceback (most recent): File"<pyshell#13>", Line 1,inch<module>Chr (1114112) VALUEERROR:CHR () Arg not inchRange (0x110000)

Python built-in functions (Ten)--CHR

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.