Python various types of conversions

Source: Internet
Author: User
#进制转换
Ord (x)                 #将一个字符转换为它的整数值    Hex (x)                 #将一个整数转换为一个十六进制字符串    Oct (x)                 #将一个整数转换为一个八进制字符串
#类型转换
int (x [, Base]) #将x转换为一个整数 Long (x [, Base]) #将x转换为一个长整数 float (x) #将x转换到一个浮点数 Complex ( Real [, Imag]) #创建一个复数 str (x) #将对象 x converted to a string repr (x) #将对象 x converted to expression string eval (str) # Used to calculate a valid Python expression in a string, and returns an object tuple (s) #将序列 s converted to a tuple list (s) #将序列 s converted to a list chr (x) #将一个整数转换为一个字符 UNICHR (x) #将一个整数转换为Unicode字符

Python various types of conversions

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.