Python-conversion between characters and character values

Source: Internet
Author: User

Conversion between characters and character values

 

In Python,Character and character value, Direct conversion, includingASCII code and lettersBetween,Unicode code and numberBetween;

You can also useMapBatch Conversion, The output is a set, useJoinThe set can be merged;

 

The Code is as follows:

 

#-*-Coding: UTF-8-*-# = # File: PrintExercise. py # Author: Wendy # Date: 2014-03-02 #==============================#eclipse pydev, conversion Between the python2.7 ''' character and character value ''' print (ord ('A') # conversion of characters to numbers print (chr (97 )) # convert a number to print (repr (unichr (8224) # repr returns a standard character representation # map each character to print (map (ord, 'ciao') # No number (97-100) mapped to print (''. join (map (chr, range (1, 97,101 ))))

Output:

 

 

97au 'hangzhou' [99,105, 97,111] abcd


 

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.