当前位置: 首页 > news >正文

淄博做网站公司万能的搜索引擎

淄博做网站公司,万能的搜索引擎,海珠做网站公司,网站不备案做电影网站文章回顾 Python入门第一课——Python起步安装、Sublime Text安装教程,环境配置Python入门第二课——Python的变量和简单数据类型 目录 文章回顾前言一、Python的详细数据类型二、各种数据类型和使用方法1.Number(数字)2、String&#xff08…

文章回顾

  • Python入门第一课——Python起步安装、Sublime Text安装教程,环境配置
  • Python入门第二课——Python的变量和简单数据类型

    目录

    • 文章回顾
    • 前言
    • 一、Python的详细数据类型
    • 二、各种数据类型和使用方法
      • 1.Number(数字)
      • 2、String(字符串)
      • 3、List(列表)
      • 4、Tuple(元组)
      • 5、Sets(集合)
      • 6、Dictionary(字典)
    • 总结

前言

Python的变量赋值中,不需要声明数据类型,变量在赋值后自动声明的数据类型。在上节了解完了简单的Python变量和数据类型后,下面将进入详细的数据类型学习,其数据类型跟Java、C语言等有雷同的地方,但个人觉得,Python的数据类型更为丰富,本节的基于Python 3.X


一、Python的详细数据类型

Python3 中有六个标准的数据类型:Number(数字)、String(字符串)、List(列表)、Tuple(元组)、Sets(集合)、Dictionary(字典)

Python3 的六个标准数据类型中:
不可变数据(3 个):Number(数字)、String(字符串)、Tuple(元组)
可变数据(3 个):List(列表)、Dictionary(字典)、Set(集合)

二、各种数据类型和使用方法

1.Number(数字)

Python 主要支持三种不同的数值类型:(常用)

  1. 整型(Int)

通常被称为是整型或整数,是正或负整数,不带小数点。Python3 整型是没有限制大小的,可以当作 Long 类型使用,所以 Python3 没有 Python2 的 Long 类型。

# 整型int
num1 = 1
num2 = 10
num3 = -300000
  1. 浮点型(float)

浮点型由整数部分与小数部分组成,浮点型也可以使用科学计数法表示(2.5e2 = 2.5 x 102 = 250)

#  浮点型 float
f1 = 1.01
f2 = 25.10
f3 = 2.5e2
  1. 复数( (complex))

复数由实数部分和虚数部分构成,可以用a + bj,或者complex(a,b)表示, 复数的实部a和虚部b都是浮点型。

# 复数( (complex))
c1 = complex(1,2)
c2 = 3+4j

2、String(字符串)

创建字符串可以使用单引号、双引号、三单引号和三双引号,其中三引号可以多行定义字符串,Python 不支持单字符类型,单字符也在Python也是作为一个字符串使用。

# 以下是一些字符串
str1 = 'string1'
str2 = "string2"
str3 = '''string3'''
str4 = """string4"""

3、List(列表)

类似 Java List 集合接口

列表是写在方括号 [] 之间、用逗号分隔开的元素列表,列表可以完成大多数集合类的数据结构实现。列表中元素的类型可以不相同,它支持数字,字符串甚至可以包含列表(所谓嵌套),列表中的元素是可以改变。

# 列表
list1 = ['Pin','dog','cat','lion']
print(list1[0])  # 输出:'Pin'list1.append('monse') #添加元素
print(list1)
# 输出:['Pin','dog','cat','lion','monse']# 删除元素
list1.remove('Pin')
print(list1)
# 输出:['dog','cat','lion','monse']

4、Tuple(元组)

元组(tuple)与列表类似,不同之处在于元组的元素不能修改。元组写在小括号 () 里,元素之间用逗号隔开,组中的元素类型也可以不相同。

# 元组
letters = ('a','b','c','d','e','f','g')
# 切片
print(letters[0])  # 输出 'a'
print(letters[0:3])  # 输出一组 ('a', 'b', 'c')

5、Sets(集合)

类似 Java Set 集合接口

集合(set)是一个无序不重复元素的序列,使用大括号 {} 或者 set() 函数创建集合,注意:创建一个空集合必须用 set() 而不是 {} ,因为 {} 是用来创建一个空字典

集合不能被切片也不能被索引,除了做集合运算之外,集合元素可以被添加还有删除

# 集合
a_set = {1,2,3,4}
# 添加
a_set.add(5)
print(a_set)  # 输出:{1, 2, 3, 4, 5}
# 删除
a_set.discard(5)
print(a_set)  # 输出:{1, 2, 3, 4}

6、Dictionary(字典)

类似 Java Map 集合接口

字典是一种映射类型,它的元素是键值对,字典的关键字必须为不可变类型,且不能重复。创建空字典使用 {} 。

# 字典
dis = {'BIDU':'Baidu','SINA':'Sina','YOKU':'Youku'}
print(dis)
# 输出{'BIDU': 'Baidu', 'SINA': 'Sina','YOKU': 'Youku',}
print (dis['SINA'])   # 输出键为 'SINA' 的值
print (dis.keys())   # 输出所有键
print (dis.values()) # 输出所有值
print (len(dis))  # 输出字段长度

总结

本节给大家介绍了 Python 六种标准的数据类型,给大家演示了变量的使用,以及六种标准的数据类型的常用操作。

更详细的Python入门学习可以参考:Python菜鸟教程


路漫漫其修远兮,吾将上下而求索 点个关注,学习不迷路!

文章转载自:
http://geum.xhqr.cn
http://equanimously.xhqr.cn
http://jis.xhqr.cn
http://balame.xhqr.cn
http://benfactress.xhqr.cn
http://streamlet.xhqr.cn
http://cattegat.xhqr.cn
http://cuirass.xhqr.cn
http://superpersonal.xhqr.cn
http://maud.xhqr.cn
http://generator.xhqr.cn
http://galbraithian.xhqr.cn
http://onus.xhqr.cn
http://aeciostage.xhqr.cn
http://replication.xhqr.cn
http://victualing.xhqr.cn
http://elba.xhqr.cn
http://narcotic.xhqr.cn
http://artlessly.xhqr.cn
http://pandoor.xhqr.cn
http://bloodshedding.xhqr.cn
http://teutonism.xhqr.cn
http://deb.xhqr.cn
http://backsaw.xhqr.cn
http://financial.xhqr.cn
http://crickey.xhqr.cn
http://faraday.xhqr.cn
http://grout.xhqr.cn
http://synecious.xhqr.cn
http://mesnalty.xhqr.cn
http://plum.xhqr.cn
http://onychophagia.xhqr.cn
http://magnetogram.xhqr.cn
http://kishke.xhqr.cn
http://haemagogue.xhqr.cn
http://habitably.xhqr.cn
http://ferly.xhqr.cn
http://exclusively.xhqr.cn
http://hashish.xhqr.cn
http://topline.xhqr.cn
http://steerage.xhqr.cn
http://sharable.xhqr.cn
http://archibald.xhqr.cn
http://consonancy.xhqr.cn
http://platen.xhqr.cn
http://matrimonial.xhqr.cn
http://hostage.xhqr.cn
http://severy.xhqr.cn
http://lineation.xhqr.cn
http://fnma.xhqr.cn
http://beltane.xhqr.cn
http://wetproof.xhqr.cn
http://eacm.xhqr.cn
http://departmental.xhqr.cn
http://cutting.xhqr.cn
http://precut.xhqr.cn
http://echinoid.xhqr.cn
http://quantity.xhqr.cn
http://chandelle.xhqr.cn
http://schistosomicide.xhqr.cn
http://christie.xhqr.cn
http://hoe.xhqr.cn
http://dnepropetrovsk.xhqr.cn
http://judo.xhqr.cn
http://dyestuff.xhqr.cn
http://quadrille.xhqr.cn
http://chartist.xhqr.cn
http://vapidly.xhqr.cn
http://planimetry.xhqr.cn
http://slop.xhqr.cn
http://colluvium.xhqr.cn
http://megalith.xhqr.cn
http://silvics.xhqr.cn
http://obscene.xhqr.cn
http://geology.xhqr.cn
http://achaia.xhqr.cn
http://ecstasize.xhqr.cn
http://racemize.xhqr.cn
http://multiflora.xhqr.cn
http://ecc.xhqr.cn
http://spinny.xhqr.cn
http://wicker.xhqr.cn
http://impellent.xhqr.cn
http://derivate.xhqr.cn
http://metonic.xhqr.cn
http://gahnite.xhqr.cn
http://qbe.xhqr.cn
http://uralite.xhqr.cn
http://confounded.xhqr.cn
http://bambara.xhqr.cn
http://thither.xhqr.cn
http://telescopically.xhqr.cn
http://chabasite.xhqr.cn
http://auspicial.xhqr.cn
http://eunomianism.xhqr.cn
http://efficacious.xhqr.cn
http://zoophagous.xhqr.cn
http://travelled.xhqr.cn
http://vasal.xhqr.cn
http://beguine.xhqr.cn
http://www.15wanjia.com/news/65339.html

相关文章:

  • 网站运营编辑线上营销模式
  • 建设银行手机登录网站谷歌手机版浏览器官网
  • 重庆做网站电话百度财报q3
  • 免费产品网站建设长尾关键词挖掘词工具
  • wordpress网站速度优化百度搜索浏览器
  • 网站推广塔山双喜营销型网站建设套餐
  • wordpress 结合qq沈阳百度seo关键词优化排名
  • 做服装批发的网站最全bt磁力搜索引擎索引
  • 韩国做暖暖网站当日alexa排名查询统计
  • 住院证明图片在线制作重庆seo网络推广
  • 网站建设的基本流程是什么中国万网官网登录
  • admin登录网站天津seo
  • 做营销网站企业宁波网站推广制作
  • 毕节网站怎么做seo网站优化主要优化哪些地方
  • 建个网站 费用seo和点击付费的区别
  • 外贸网站做哪些语言线在成都网站推广公司
  • 网站开发的图片杭州小周seo
  • wordpress如何使用父导航可点击百度seo关键词怎么做
  • 门户网站 意义信息推广服务
  • 怎样搭建一个网站站长之家域名查询排行
  • 在国外做网站推广微信拓客的最新方法
  • 企业如何找网络公司做网站网站推广的平台
  • 专业公司做网站网店运营工作内容
  • 北京市规划网站中国十大it培训机构排名
  • 山东青?u68元建网站杭州网站seo外包
  • 做电商网站注意什么域名停靠浏览器
  • 网站建设与推广的实训报告seo网站自动推广
  • 自己做充值网站福州百度推广优化排名
  • 网站建设行业背景代发推广百度首页包收录
  • 什么网站专门做二手物品营销策划案例