栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

关于python基础练习的小结(一)

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

关于python基础练习的小结(一)

ll list(range(1, 16)) # 用range来创建数据,list()转化为列表类型 ll map(lambda x: x * 3, ll) print(ll) print(list(ll)) # func: all() print( all() 全部元素非 False,ret True;nor False ) print(all([ , a , 7755])) print(all([313, a ])) print(all([0])) # func: any() print( any() 任意元素 True,ret True;全 False,ret False ) print(any([ , a , 7755])) print(any([313, a ])) print(any([0])) # sort() sorted() newList list(range(3, 13)) random.shuffle(newList) print( random sort (start): , newList) newList.sort() print( 默认升序排序 , newList) # 默认升序排列 newList.sort(reverse True) print( 倒叙排序 , newList) # 倒叙排列 newList.sort(key lambda x: len(str(x))) print( 按照字符串长度排序 , newList) # 按照字符串长度排序 sorted(newList) print( sorted (two examples /confirm/i): ) print(newList) print(sorted(newList)) # 这两个print说明sorted并不影响到newList # zip() lt1 [3, 7, 1, 0, 8] lt2 [ D , I , O , P ] lt3 [ D , I , O , P , MOD ] zipList1 list(zip(lt1, lt2)) # 非等长list的zip() zipList2 list(zip(lt1, lt3)) # 等长list的zip() print(zipList1) print(zipList2)
# -*- coding: utf-8 -*-
# CloudyTenderness
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/267613.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号