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

單引號字符串

雙引號字符串

轉義字符--輸出雙引號&單引號

轉義字符--換行

按照輸入格式打印字符串

相關文章
相關標籤/搜索