python开发[第二篇]------str的7个必须掌握的方法以及五个常用方法
在Python中 基本数据类型有 str int boolean list dict tuple等 其中str的相关方法有30多个 但是常用的就以下7个
join
# split
# find
# strip
# upper
# lower
# replace
除了以上7个常用方法外,还有个五基本方法务必牢记 在以后会经常用到
一、for循环
# for 变量名 in 字符串:
# 变量名
# break
# continue
# index = 0
# while index < len(test):
# v = test[index]
# print(v)
#
# index += 1
# print('=======')
# for zjw in test:
# print(zjw)
# test = "让技术成为你的核心竞争力"
# for item in test:
# print(item)
# break
# for item in test:
# continue
# print(item)
# 二、索引,下标,获取字符串中的某一个字符
# v = test[3]
# print(v)
# 三、切片
# v = test[0:-1] # 0=< <1
# print(v)
# 四、获取长度
# Python3: len获取当前字符串中由几个字符组成
# v = len(test)
# print(v)
# 五、获取连续或不连续的数字,
# Python2中直接创建在内容中
# python3中只有for循环时,才一个一个创建
# r1 = range(10)
# r2 = range(1,10)
# r3 = range(1,10,2)
# 帮助创建连续的数字,通过设置步长来指定不连续
# v = range(0, 100, 5)
#
# for item in v:
# print(item)
最新文章
- Server.Transfer 和 Response.Redirect 用法区别
- appach2.4 + php7 +mysql5.7.14 配置
- sharePoint 2016 弃用和删除的功能
- 友盟SDK实现分享
- 两个list取不同值
- sql语句与 数据库
- qq临时会话设置
- 【USACO】Milking Cows
- A Tour of Go Exercise: Images
- 【转】MSSQL获取指定表的列名信息,描述,数据类型,长度
- 解决GDB输出Qt内置类型的显示问题
- SQL Server2005使用CTE实现递归
- Swift - .plist文件数据的读取和存储
- 【Linux探索之旅】第一部分第三课:测试并安装Ubuntu
- JSP精华知识点总结
- Android Studio 3.0+ Annotation processors must be explicitly declared now
- webpack-dev-server的执行逻辑
- MyBatis项目快速搭建及MySQL一个Statement支持多条命令参数
- html5获取地理位置信息API
- tomcat重启步骤