标签:spl find 组成 dex lis 常用方法 竞争力 基本数据 tuple
在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)
python开发[第二篇]------str的7个必须掌握的方法以及五个常用方法
标签:spl find 组成 dex lis 常用方法 竞争力 基本数据 tuple
原文地址:https://www.cnblogs.com/lijun6/p/9307768.html