入门python
m0_58376298
这个作者很懒,什么都没留下…
展开
-
集合的相关内容
集合:python语言提供的内置数据结构,与列表,字典一样都属于可变的序列,集合是没有val的字典。特点:无序,不重复集合的创建:直接{} s={'python','hello',90} 使用内置函数set() s=set(range(6)) print(set([3,2,61]) 将列表以集合的方式输出 print(set((3,1,45,56)) 将元组以集合的方式输出 print(set()...原创 2021-12-09 12:40:13 · 597 阅读 · 0 评论 -
元组的相关内容
元组的创建:第一种方式,使用() #小括号可以省略t=('python','world',98)print(t)print(type(t))第二种创建方式,使用内置函数tuple()t1=tuple(‘pyhon’,‘world’,98)print(t1)只包含一个元组的元素需要使用逗号和小括号t=(10,)空列表: lst=[] lst1=list()空字典: d={} d2=d...原创 2021-12-08 15:43:40 · 261 阅读 · 0 评论 -
字典的创建
使用{}创建字典scores={'张三':100,‘李四’:88,‘王五’:63} #键值对print(scores)print(type(scores))使用内置函数dict()创建字典student=dict(name='jack',age=20)print(student)空字典 d={}字典元素的获取scores={'张三':100,‘李四’:95,‘王五’:45}第一种方式: print(scores['张三'])第二种方式: pri...原创 2021-12-08 13:34:55 · 401 阅读 · 0 评论 -
python
列表生成式lst=[i*i for i in range(1,10) 产生1到9的列表原创 2021-12-07 10:07:02 · 382 阅读 · 0 评论 -
Python
布尔运算符:and or not (对布尔操作数取反)in 与 notins=‘helloworld’print(’w‘ in s)#Trueprint ('k' not in s) #True位运算 ,将数据转成二进制进行计算位与& 对应数位都是1,结果数位才是1,否则为0位或| 对应数位都是0,结果才是0,否则为1左移位运算符<< 高位溢出舍弃,低位补0,左移一位,...原创 2021-12-07 10:03:02 · 65 阅读 · 0 评论 -
python
print(520)print(3+1)print('hello\nworld') 换行输出print('hello\tworld') 加空格符print('hello\rworld')world将hello覆盖print(‘hello\bworld’) 退一格print ('老师说:\大家好'\'')原字符:不希望转义字符起作用,就在字符串之前加上r或Rprint(r'hello\nworld')print(chr(0b100111001011000)...原创 2021-11-27 15:57:49 · 551 阅读 · 0 评论