python
python的相关基础
pan_nworld
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Python-------------字符串的操作
1、字符串查询操作的方法 #字符串的查询操作 s='hello,hello' print(s.index('lo')) #3 print(s.find('lo')) #3 print(s.rindex('lo')) #9 print(s.rfind('lo')) #9 3 3 9 9 2、字符串大小写转换操作的方法 #将字符串转换成大写 s='hello,python' a=s.upper() #转成大写之后,会产生一个新的字符串对象 pr.原创 2020-10-07 16:37:55 · 602 阅读 · 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) 1948973069568 1948973069568 194897.原创 2020-10-05 20:54:28 · 328 阅读 · 1 评论 -
Python-----------集合
1、集合的创建原创 2020-10-06 15:51:19 · 208 阅读 · 0 评论 -
Python------修改字符串的大小写
title():以首字母大写的方式显示每个单词 upper(): 将字符串改为全部大写 lower(): 将字符串改为全部小写 name="paul mike" print(name.title()) print(name.upper()) print(name.lower()) Paul Mike PAUL MIKE paul mike原创 2020-09-21 22:07:46 · 174 阅读 · 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 · 2464 阅读 · 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 · 791 阅读 · 0 评论
分享