码迷,mamicode.com
首页 > 编程语言 > 详细

python基础(十)--元组

时间:2020-04-01 19:47:59      阅读:81      评论:0      收藏:0      [点我收藏+]

标签:iba   转化   pen   split   只读   split()   range   ++   python基础   

#元祖 只读列表,可循环查询,可切片。
#儿子不能改,孙子可能可以改。
# tu = (1,2,3,‘alex‘,[2,3,4,‘taibai‘],‘egon‘)
# # print(tu[3])
# # print(tu[0:4])
# # for i in tu:
# # print(i)
# tu[4][3]=tu[4][3].upper()
# print(tu)
# tu[4].append(‘sb‘)
# print(tu)

# s = ‘alex‘
# s1 = ‘sb‘.join(s)
# print(s1)
#列表转化成字符串 list -----> str join
# li = [‘taibai‘,‘alex‘,‘wusir‘,‘egon‘,‘女神‘,]
# s = ‘++++‘.join(li)
#str ----->list split()
# print(s)


#range [1,2,3,4,5,6,.......100........]

# for i in range(3,10):
# print(i)
# for i in range(10):
# print(i)
# for i in range(0,10,3):
# print(i)
# for i in range(10,0,-2):
# print(i)
# for i in range(10,-1,-2):
# print(i)

li = [1,2,3,5,‘alex‘,[2,3,4,5,‘taibai‘],‘afds‘]
# for i in li:
# if type(i) == list:
# for k in i:
# print(k)
# else:print(i)

for i in range(len(li)):
if type(li[i]) == list:
for j in li[i]:
print(j)
else:print(li[i])

python基础(十)--元组

标签:iba   转化   pen   split   只读   split()   range   ++   python基础   

原文地址:https://www.cnblogs.com/qingmuzi/p/12614487.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!