python基本数据类型和用法

 

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

1、int 整形范围

How Big Is an int?python

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.ide

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.this

Python3中整形能够用任意大小,不会出现溢出状况。spa

jupyter notebook中测试以下:3d

2、Strings 字符串

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

单引号字符串

双引号字符串

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

转义字符--换行

按照输入格式打印字符串

相关文章
相关标签/搜索