#!/usr/bin/env python
# -*- coding:utf-8 -*-
# 元组:又叫只读列表 可循环查询,可切片 ps:儿子不能变,孙子可能可以变
tu = (1, 2, 3, 'alex', [2, 3, 4, 'taibai'], 'egon')
print(tu[3])
print(tu[0:4])
for index in tu:
print(index)
print(tu)
tu[4][3] = tu[4][3].upper()
# 能修改的原因是,这步操作的对象是一个list
print(tu)
tu[4].append('sb')
print(tu)
s = 'alex'
s1 = '_'.join(s)
# 在可迭代对象中添加连接符
# iterable:可迭代对象,除了数字和布尔
print(s1)
# 字符串 列表互相转换
li = ['xiaohu', 'alex', 'wusir','tiger', '女神']
s = '+++'.join(li)
# join返回的是一个字符串
print(s)
list_s = s.split('+++')
print(list_s)
# range[1,2,3,4,......,1000,.....],顾头不顾尾
for i in range(0, 10, 3):
print(i)
for i in range(10, 0, -1):
print(i)
for i in range(0, 10, -1):
print(i)
li = [1, 2, 3, 5, 'alex', [2, 3, 4, 5, 'taibai'], 'afds']
for i in li:
if type(i) == list:
for j in i:
print(j)
else:
print(i)