python3学习笔记--条件控制用法整理

if if_stmt ::= "if" assignment_expression ":" suite ("elif" assignment_expression ":" suite)* ["else" ":" suite] 用法: if EXPRESSION1: SUITE1elif EXPRESSION2: SUITE2else: SUITE 常用的操作符: "<":小于 "<=":小于等于 ">":大于 ">=":大于等于 "==":等于 "!=":不等于 "and":并且 "or":或者 with with_stmt ::= "with" ( "(" with_stmt_contents ","? ")" | with_stmt_contents ) ":" suitewith_stmt_contents ::= with_item ("," with_item)*with_item ::= expression ["as" target] 用法: with EXPRESSION as TARGET: SUITE或者with A() as a, B() as b: SUITE或者with A() as a: with B() as b: SUITE或者with ( A() as a, B() as b,): SUITE match(3.10新特性) match_stmt ::= 'match' subject_expr ":" NEWLINE INDENT case_block+ DEDENTsubject_expr ::= star_named_expression "," star_named_e...

avatar 龙儿之家 发表于 2021-12-29

python3学习笔记--两种排序方法

列表排序方法 sort():仅对list对象进行排序,会改变list自身的顺序,没有返回值,即原地排序 sorted():对所有可迭代对象进行排序,返回排序后的新对象,原对象保持不变; sort() list.sort(key=None, reverse=False) key:设置排序方法,或指定list中用于排序的元素; reverse:升降序排列,默认为升序排列; 例子: nums = [2, 3, 5, 1, 6]nums.sort()print(nums) # [1, 2, 3, 5, 6]nums.sort(key=None, reverse=True)print(nums) # [6, 5, 3, 2, 1] students = [('john', 'C', 15), ('jane', 'A', 12), ('dave', 'B', 10)]students.sort(key=lambda x: x[2]) # 按照列表中第三个元素排序print(students) # [('dave', 'B', 10), ('jane', 'A', 12), ('john', 'C', 15)] sorted() sorted(iterable [, key[, reverse]]) key :设置排序方法,或指定迭代对象中,用于排序的元素; reverse :升降序排列,默认为升序排列; 例子: nums = [2, 3, 5, 1, 6]newNums = sorted(nums)print(nums) # [2, 3, 5, 1, 6]print(newNums) # [1, 2, 3, 5, 6]students = [('john', 'C', 15), ('jane', 'A', 12), ('dave', 'B', 10)]newStude...

avatar 龙儿之家 发表于 2021-12-29

JavaScript 实用技巧

字符串

avatar Eurkon 发表于 2021-12-25

ECharts 迁徙地图


avatar Eurkon 发表于 2021-10-15

ECharts 标签地图


avatar Eurkon 发表于 2021-10-01

ECharts 热力地图


avatar Eurkon 发表于 2021-09-15

ECharts 散点地图


avatar Eurkon 发表于 2021-09-01