test = 'alex'标签:11,test2,item,Python,魔法,len,test,字符串,print From: https://www.cnblogs.com/liu-zhijun/p/18337174
v = test[2] # 索引,下标,获取字符串中的某一个字符
print(v, -1)
test = 'alexsasdf'
v = test[0:3] # 0=<v<3
print(v, -2)
v1 = test[0:-1] # 切片
print(v1, -3)
v2 = len(test)
print(v2, -4)
v3 = len("我是中国人") # len获取当前字符串中由几个字符组成,python2.7里面一个汉字是3个则为15
print(v3, -5)
li = [11, 22, 33, 44, 55, 'asdfg'] # 获取的是以逗号为隔,而不是以字长
v4 = len(li)
print(v4, -6)
test = '我是中国人你是'
count = 0
while count < len(test):
v = test[count]
print(v)
count += 1
print('=========,-7')
for zgr in test: # for循环和上面的功能是一样的
print(zgr, -8)
name = 'wohaogaoxing'
age = '25'
info = name + age
print(info)
# 字符串一旦创建,不可修改
# 一旦修改或者拼接,都会造成重新生成字符串
test = '我是中国人你是'
for item in test:
print(item)
break
for item in test:
continue
print(item)
v=range(100) #帮助创建连续的数字,通过设置步长来指定不连续
print(v)
for item in v:
print(item)
v=range(0,100,5)
print(v)
for item in v:
print(item)
test=input('>>>')
for item in test:
print(item)
test2=input('>>>')
print(test2)
le=len(test2)
print(le)
r=range(0,le)
for item in r:
print(item,test2[item])
test=input('>>>')
for item in range (0,len(test)):
print(item,test[item])