python中integer用法_python基本数据类型和用法

Python数据类型详解

python基本数据类型和简单用法

一、int 整形范围

How Big Is an int?

In Python2, the size of an int was limited to 32 bits, which is enough to store an integer from -2,147,483,648 to 2,147,483,647. A long can store 64 bits. Integers larger than the range will cause Integer Overflow.

In case you wonder where does this range come from. Computers store numbers in its binary format, 32 bits means we have 32 binary bits to store a number. That's why we can only store 232232 different integers. Since we want to store both positive numbers and negative numbers at the same time, each side will get 231231 numbers, which is 2,147,483,648.

In Python3, an int can handle any integer no matter how large it is without causing overflow.

Python3中整形可以用任意大小,不会出现溢出情况。

jupyter notebook中测试如下:

2a6e5e1fc33e46554491db2356e7bf6f.png

二、Strings 字符串

The strings is a sequence of characters. strings是character组成的序列。

单引号字符串

cee0ece6ad400173a55ac15952c5b69c.png

双引号字符串

3417f888155ee669d6a220f5228fbe87.png

转义字符--输出双引号&单引号

37116e1d7929e7a6afce22f2953bc581.png

转义字符--换行

42524c28fffac2a37eb269c320512be2.png

按照输入格式打印字符串

5310a1313657d5e8ad685dd57eced111.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值