python中的一些类型转换函数小结

WBOY
Release: 2016-06-16 08:46:49
Original
1225 people have browsed it

函数                         描述
int(x [,base ])              将x转换为一个整数
long(x [,base ])             将x转换为一个长整数
float(x )                    将x转换到一个浮点数
complex(real [,imag ])       创建一个复数
str(x )                      将对象 x 转换为字符串
repr(x )                     将对象 x 转换为表达式字符串
eval(str )                   用来计算在字符串中的有效Python表达式,并返回一个对象
tuple(s )                    将序列 s 转换为一个元组
list(s )                     将序列 s 转换为一个列表
chr(x )                      将一个整数转换为一个字符
unichr(x )                   将一个整数转换为Unicode字符
ord(x )                      将一个字符转换为它的整数值
hex(x )                      将一个整数转换为一个十六进制字符串
oct(x )                      将一个整数转换为一个八进制字符串

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!