1. Python中的变量赋值
单变量赋值:
counter = 100#赋值整型变量
miles = 1000.0#浮点型
name = "John"#字符串
多变量赋值:
a = b = c= 1 #三个变量的值都为1
a, b, c =1, 2, "john" #分别为三个变量赋值
2. Python中的数据类型
Python有五个标准的数据类型:
1. Numbers(数字)
1)不可改变的数据类型:
当其类型被改变时,将会赋值给一个新的对象。当对变量赋予了数值后,这个对象就会被创建,可通过del语句删除对这些对象的引用。
2)Python支持的数字类型:
int(有符号整型,如0x69,10);long(长整型[也可以代表八进制和十六进制],如-4721885298529L,Python用数字后面的L表示长整型);float(浮点型,如70.2E-12);complex(复数,如4.53e-7j)。
3)Python数据类型转换:
int(x [,base ]) 将x转换为一个整数
long(x [,base ]) 将x转换为一个长整数
float(x ) 将x转换到一个浮点数
complex(real [,imag ]) 创建一个复数
str(x ) 将对象 x 转换为字符串
repr(x ) 将对象 x 转换为表达式字符串
eval(str ) 用来计算在字符串中的有效Python表达式,并返回一个对象
tuple(s ) 将序列 s 转换为一个元组
list(s ) 将序列 s 转换为一个列表
chr(x ) 将一个整数转换为一个字符
unichr(x ) 将一个整数转换为Unicode字符
ord(x ) 将一个字符转换为它的整数值
hex(x ) 将一个整数转换为一个十六进制字符串
oct(x ) 将一个整数转换为一个八进制字符串
Python之<基础知识>:https://www.songqinnet.com/article/932
Python之<字符串操作>:https://www.songqinnet.com/article/934
Python之<变量类型>:https://www.songqinnet.com/article/937
文章来源: 松勤网
睡前故事:https://www.nanss.com/yuedu/2910.html
项目可行性研究报告:https://www.nanss.com/gongzuo/3029.html
别相信任何人读后感:https://www.nanss.com/yuedu/4353.html
热爱祖国的简短句子:https://www.nanss.com/xuexi/4685.html
我终于可以不再爱你了:https://www.nanss.com/yuedu/4556.html
灯谜:https://www.nanss.com/shenghuo/4696.html
快乐每一天:https://www.nanss.com/wenan/4481.html
妈妈给女儿最暖心短句:https://www.nanss.com/yulu/3823.html
幼儿园月工作总结:https://www.nanss.com/gongzuo/3327.html
座右铭:https://www.nanss.com/shenghuo/3126.html
事故调查报告:https://www.nanss.com/shenghuo/3388.html
大鱼海棠经典台词:https://www.nanss.com/shenghuo/4674.html
超帅的名字:https://www.nanss.com/mingcheng/4115.html
总结报告:https://www.nanss.com/gongzuo/3141.html
满族八大姓:https://www.nanss.com/shenghuo/4949.html
霸气昵称4个字:https://www.nanss.com/mingcheng/4644.html
2022经典霸气语句:https://www.nanss.com/yulu/3832.html
授权书模板:https://www.nanss.com/gongzuo/4732.html
眼镜店广告语:https://www.nanss.com/shenghuo/3955.html
好听的蛋糕店名字:https://www.nanss.com/shenghuo/4948.html
qq备注:https://www.nanss.com/mingcheng/3604.html
心烦意乱心情说说:https://www.nanss.com/wenan/4619.html
绝对看不懂的表白:https://www.nanss.com/shenghuo/4141.html
英文游戏名字:https://www.nanss.com/mingcheng/3867.html
一辈子闺蜜的经典句子:https://www.nanss.com/yulu/4323.html
实习报告总结:https://www.nanss.com/xuexi/2999.html
好句子大全唯美:https://www.nanss.com/xuexi/3636.html
漫画作文:https://www.nanss.com/xuexi/3184.html
父与子读后感:https://www.nanss.com/xuexi/2954.html
电话销售话术:https://www.nanss.com/gongzuo/4229.html