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中测试如下:

二、Strings 字符串
The strings is a sequence of characters. strings是character组成的序列。
单引号字符串

双引号字符串

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

转义字符--换行

按照输入格式打印字符串

python基本数据类型和简单用法的更多相关文章
- (数据科学学习手札54)Python中retry的简单用法
一.简介 retry是一个用于错误处理的模块,功能类似try-except,但更加快捷方便,本文就将简单地介绍一下retry的基本用法. 二.基本用法 retry: 作为装饰器进行使用,不传入参数时功 ...
- python optparse模块的简单用法
# coding = utf-8 from optparse import OptionParser from optparse import OptionGroup usage = 'Usage: ...
- python之logging模块简单用法
前言: python引入logging模块,用来记录自己想要的信息.print也可以输入日志,但是logging相对print来说更好控制输出在哪个地方.怎么输出以及控制消息级别来过滤掉那些不需要的信 ...
- python中列表的简单用法
1.定义list >>> li = ["a", "b", "mpilgrim", "z", " ...
- python基本数据类型list,tuple,set,dict用法以及遍历方法
1.list类型 类似于java的list类型,数据集合,可以追加元素与删除元素. 遍历list可以用下标进行遍历,也可以用迭代器遍历list集合 建立list的时候用[]括号 import sys ...
- python timeit模块简单用法
timeit模块提供了一种简便的方法来为Python中的小块代码进行计时. 模块调用函数,stmp为要测试的函数,setup为测试环境,number为运行次数 timeit.timeit(stmt=) ...
- python的变量和简单的数据类型
决定学习python这门语言了,本人资质愚钝,只会把学到的东西记录下来,供自己查漏补缺,也可以分享给和我一样正在学习python语言的人,若在记录中存在什么错误,希望多多批评指正,谢谢. Python ...
- python lambda表达式简单用法【转】
python lambda表达式简单用法 1.lambda是什么? 看个例子: g = lambda x:x+1 看一下执行的结果: g(1) >>>2 g(2) >>& ...
- python制作简单excel统计报表2之操作excel的模块openpyxl简单用法
python制作简单excel统计报表2之操作excel的模块openpyxl简单用法 # coding=utf-8 from openpyxl import Workbook, load_workb ...
随机推荐
- python 编程基础-字典类型和方法
定义:字典是一种key-vlaue的数据类型. 字典特性KEY值必须是唯一,且可hash的(不可变数据类型),无索引,无序的(因为有KEY),查找速度快 语法:info = {'stu1101':&q ...
- NET Core准备:使用Hyper-V安装Ubuntu Server 16.10
NET Core准备:使用Hyper-V安装Ubuntu Server 16.10 概述 Hyper-V是微软的一款虚拟化产品,和VMWare一样采用的hypervisor技术.它已经被内嵌到Win1 ...
- c++笔记3
一基本语法: 1.1 字符串:支持标准C的 const char* pch=0/"";//不指向任何对象和指向空字符串.C++提供的string类可提供字符串的所有操作,最好是融合 ...
- JsonModel&AFNetWorking
// HttpManager.h // JsonModel&AFNetWorking // // Created by qianfeng on 15/7/21. // Copyright (c ...
- Git入门学习总结
用了两天时间看完廖雪峰老师的git教程(http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b0 ...
- Android Error:Could not run build action using Gradle installation
错误内容: Error:Could not run build action using Gradle installation ‘D:\AndroidStudio\AS2.x\gradle\grad ...
- SharePoint 2013 缺少站点保存为模板选项
如果您尝试在SharePoint Server 2013中保存站点,我们没有看到“将站点另存为模板”选项,则可能是因为该站点已启用站点发布功能.如 之前文章提到 “SharePoint 2010 缺少 ...
- Windows Azure 配置Active Directory 主机(2)
前一篇概况给大家介绍了,在云端部署一台DC 需要满足一些条件,接下来进入正题,云端VM安装域控制器具体步骤. 步骤1 :验证 主DC 的静态 IP 地址 1.登录到 Corp 网络上的 主DC. 2. ...
- ZOJ 3471 Most Powerful (状压DP,经典)
题意: 有n个原子,每当两个原子碰撞时就会产生能量,并且消耗其中一个原子.已知每两个原子碰撞时消耗其中指定一个原子所产生的能量,问最多能产生多少能量? 思路: 一开始以为是找一个有序序列,使得能量最大 ...
- 随记:UWP开发中怎么使当前页面拓展到标题栏
public sealed partial class MainPage : Page { public MainPage() { this.InitializeComponent(); CoreAp ...