
python
python的相关基础
pan_nworld
这个作者很懒,什么都没留下…
展开
-
Python-------------字符串的操作
1、字符串查询操作的方法#字符串的查询操作s='hello,hello'print(s.index('lo')) #3print(s.find('lo')) #3print(s.rindex('lo')) #9print(s.rfind('lo')) #933992、字符串大小写转换操作的方法#将字符串转换成大写s='hello,python'a=s.upper() #转成大写之后,会产生一个新的字符串对象pr.原创 2020-10-07 16:37:55 · 559 阅读 · 0 评论 -
Pythin----------------元组
1、元组可变序列与不可变序列'''可变序列(可以对序列执行增、删、改操作,对象地址不发生变化) 列表,字典'''lst=[10,20,45]print(id(lst))lst.append(300)print(id(lst))'''不可变序列(没有增删改的操作) 字符串、元组'''s='hello'print(id(s))s=s+'world'print(id(s))print(s)19489730695681948973069568194897.原创 2020-10-05 20:54:28 · 304 阅读 · 1 评论 -
Python-----------集合
1、集合的创建原创 2020-10-06 15:51:19 · 187 阅读 · 0 评论 -
Python------修改字符串的大小写
title():以首字母大写的方式显示每个单词upper(): 将字符串改为全部大写lower(): 将字符串改为全部小写name="paul mike"print(name.title())print(name.upper())print(name.lower())Paul MikePAUL MIKEpaul mike原创 2020-09-21 22:07:46 · 155 阅读 · 0 评论 -
Python----------列表操作
1、列表的创建与删除lst=["hello","world",98] #使用中括号方式创建print(lst)lst2=list(["hello","world",98]) #使用内置对象创建print(lst2) 结果:['hello', 'world', 98]['hello', 'world', 98]2、列表的查询操作 获取列表中指定元素的索引lst=["hello","world",98,"hello"] #如果列表中...原创 2020-09-30 21:47:15 · 2375 阅读 · 0 评论 -
Python---------字典
1.字典的创建 """字典的创建方式""""使用{}创建字典"scores={"张三":100,"李四":98,"王五":45}print(scores)print(type(scores))"第二种创建 dict()"student=dict(name='jack',age=20)print(student)"创建空字典"d={}print(d){'张三': 100, '李四': 98, '王五': ...原创 2020-10-05 16:46:10 · 743 阅读 · 0 评论