- 博客(12)
- 收藏
- 关注
原创 字典的常用操作,map zip的使用
# 字典是一个可变的数据类型# 创建空字典dic = {}print(type(dic)) # <class 'dict'># 创建字典(1) 元素不限,可以是任何数据类型zbq_infor = {"addr": "Hebei", "age": "36", "hobbit": ["play basketball", "play football"]}# 注意1 键只能是不可变的数据类型# zbq_infor = {["adder"]:"Hebei"} TypeE.
2021-07-07 01:31:17
236
原创 元组的基本操作
# 元组可以有2中创建方法# 第一种 直接创建tu = () # ()print(type(tu)) # <class 'tuple'># 第二种 通过类创建tu1 = tuple()print(type(tu)) # <class 'tuple'># tu2 = tuple(123)# print(type(tu2)) TypeError: 'int' object is not iterable 可迭代.
2021-07-06 00:34:18
239
原创 常用的内置函数,列表排序即翻转
# 常用的内置方法和函数# <class 'builtin_function_or_method'> 内置的函数和方法print(type(len)) # <class 'builtin_function_or_method'>print(type(max)) # <class 'builtin_function_or_method'>print(type(min)) # <class 'builtin_function_or_meth.
2021-07-04 11:28:03
171
原创 基本数据类型-列表
# 可以对列表进行 修改、切片、追加、删除、嵌套、迭代、成员判断 操作# 列表的创建有2种:# 其中一:[] 以英文状态下创建的方括号 创建空的列表li_1 = []print(type(li_1)) # <class 'list'># 列表中的元素是任意类型的,元素可以重复。li_2 = ["hello", 20, 20.0, True, 20]# 其中二:通过类去创建列表 list()# list() -> new empty list# list.
2021-07-03 22:48:54
129
原创 基础数据类型-字节
创建字节有2中方法,其中: 一、 创建字节 b""bt_1 = b'hello'print(bt_1)print(type(bt_1)) # <class 'bytes'>二、创建字节 bytes(string, encoding[, errors]) -> bytesGBK:中国码 utf-8:万国码bt_2 = bytes("hello", encoding="utf-8")print(bt_2)print(type(bt_2))字节和字符串之间的转
2021-07-03 19:58:11
189
原创 基础数据类型-字符串 列表 字节
字符串s1 = "hello python""""S.find(sub[, start[, end]]) -> int Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in s
2021-07-03 18:42:25
123
原创 基础数据类型-数字运算
1、dicimal 0x 十六进制 hex()十进制转十六进制 0o oct() 十进制转八进制 0b bin() 十进制转二进制import math #导入标准库print(mach.ceil(4.1)) # 向下取整print(mach.floor(4.5)) #向上取整print(mach.pow(2.3)) #2**3--->2的三次方内置方法 ...
2021-07-01 02:21:48
449
原创 python 预算符-2
1、成员运算符in 判断制定某个值是否在制定序列中,在则返回Truenot in 判断制定某个值是否在制定序列中,不在则返回Truename = "potato"class_1 = ["apple", "orange", "banana", "potato"]if name in class_1: print("显示在") #返回的是Trueelse: print("显示不在")2、身份运算符is 判断2个对象的内存地址是否一致,是则返回Truei
2021-06-27 02:30:32
163
原创 python运算符
print(9/ 3) # "/"返回的都是浮点数print(10 // 3) # "//" 整除,返回的结果是3.333333333333333335 向下取整 3 print(-10 // 3) # "//" 整除,返回的结果是-3.333333333333333335 向下取整 -4 print(10% 3) # "%" 取余,返回的结果是1print(-10% 3) # "%" 取...
2021-06-26 09:06:58
1591
1
原创 变量与常量 input(),print()
变量小练习1.打印输出–>小宇的年龄:182.打印输出–>小宇的年龄是18,性别为女性方法1:age = 18#用,将str和 0、int 进行连接,输出print(“小宇的年龄:”,age)方法2:age = 18#强制把int转化成字符串,用+号进行连接print(“小宇的年龄:” + str(age) )方法3:age = 18sex = “female”print(“小宇的年龄:”,age ,“性别为” ,sex)方法4:age = 18sex = “fema
2021-06-21 07:21:36
353
原创 python运算符
python标识符所谓的标识符就是对变量、常量、函数、类等对象起的名字。我们通过type()函数输出数据类型输入 type(1) 输出 <class “int”>输入 type(1.1) 输出 <class “float”>输入 type(“字符串”) 输出 <class “str”>输入 type(True) 输出 <class “pool”>命名规则1、严格区分
2021-06-19 22:13:22
180
原创 Python 初学环境搭建
Python 环境的搭建1、“Python”不是内部或外部命令,也不是可运行的程序或批处理文件。解释:可执行程序没有添加到系统环境当中,
2021-06-18 02:09:00
318
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅