GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Python/python2/Type_conversion.md at master · codeYDH/Python

Expand file tree

/

Type_conversion.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
19 lines (17 loc) · 1.03 KB
/

Type_conversion.md

Copy path

File metadata and controls

19 lines (17 loc) · 1.03 KB
Raw
Copy raw file
Download raw file
Edit and raw actions

三、基本数据类型转换

方法 说明
int(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 ) 将一个整数转换为一个八进制字符串

注:在 Python 3 里,只有一种整数类型 int,表示为长整型,没有 python2 中的 Long。

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.