会员
周边
新闻
博问
闪存
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
就当笔记吧
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
19
20
21
22
23
24
25
26
27
···
49
下一页
2023年9月6日
Python内置函数 - enumerate, range, max, len
摘要: 1, enumerate(可迭代对象, index_base) from collections.abc import Iterator my_list = ["aa", "b", "c"] result = enumerate(my_list) # 迭代器: 每次返回一个元组, tuple(ind
阅读全文
posted @ 2023-09-06 22:41 yanghui01
阅读(71)
评论(0)
推荐(0)
2023年9月4日
Python内置函数 - zip
摘要: 1, zip(可迭代对象1, 可迭代对象2...) from collections.abc import Iterator my_list_1 = [1, 2, 3, 4] my_list_2 = [6, 7, 8] result = zip(my_list_1, my_list_2) # 该迭代
阅读全文
posted @ 2023-09-04 23:37 yanghui01
阅读(30)
评论(0)
推荐(0)
Python内置函数 - map, reduce, filter, sorted
摘要: 1, map(fn, 可迭代对象) 参数fn为一个参数的函数 lambda方式 my_list = [2, 3, 4, 5] result = map(lambda x: x * x, my_list) # 返回元素平方值的迭代器 print(type(result)) # <class 'map'
阅读全文
posted @ 2023-09-04 23:27 yanghui01
阅读(27)
评论(0)
推荐(0)
Python使用 - 用yield实现生成器
摘要: from collections.abc import Iterator def test_yield(n): for i in range(n): yield i * 2 # 暂停在当前步骤, 返回值, 下次继续从暂停位置继续 return -1 my_gen = test_yield(3) pr
阅读全文
posted @ 2023-09-04 23:25 yanghui01
阅读(44)
评论(0)
推荐(0)
Python使用 - Iterable, Iterator
摘要: Iterable: 表示可迭代对象, 用于获取迭代器(实现__iter__函数来返回迭代器) Iterator: 表示迭代器,用于遍历元素(通过__next__函数),迭代器也是可迭代对象 from collections.abc import Iterable, Iterator my_list
阅读全文
posted @ 2023-09-04 23:18 yanghui01
阅读(65)
评论(0)
推荐(0)
Python入门 - 推导式
摘要: 推导式是什么? 用于创建容器对象的一种语法,主要用于创建list, dict, set, tuple。 1, list推导式 遍历+条件+产生的元素,用[]包装产生的每一个元素,其中条件是可选的。 my_list = [1, 2, 3] result = [elem + 1 for elem in
阅读全文
posted @ 2023-09-04 23:14 yanghui01
阅读(32)
评论(0)
推荐(0)
Python使用 - 数学函数
摘要: 三角函数 rad_30 = math.radians(30) rad_45 = math.radians(45) rad_60 = math.radians(60) rad_90 = math.radians(90) print(math.sin(rad_30)) # 0.5 print(math.
阅读全文
posted @ 2023-09-04 23:08 yanghui01
阅读(49)
评论(0)
推荐(0)
Python入门 - 类型转换
摘要: int, float print(int(1.2)) # 1 print(int("1")) # 1 print(int("0b11", 2)) # 3 print(int("27", 8)) # 23 print(int("0xF", 16)) # 15 print(int("0x1F", 16)
阅读全文
posted @ 2023-09-04 23:05 yanghui01
阅读(27)
评论(0)
推荐(0)
Python使用 - 匿名函数lambda
摘要: 例1 fn = lambda x, y: x + y print(type(fn)) # <class 'function'> print(fn(1, 2)) # 3 例2 def add(x, y): return x + y print(type(add)) # <class 'function
阅读全文
posted @ 2023-09-04 23:03 yanghui01
阅读(28)
评论(0)
推荐(0)
2023年8月31日
Bounds和Rect的区别
摘要: Bounds: 表示的是长方体, 用center和extends(halfSize)表示Rect: 表示二维矩形, 用左下角和size表示 根据min, max创建Bounds 写法1: public static Bounds GetBounds(Vector3 vMin, Vector3 vMa
阅读全文
posted @ 2023-08-31 00:09 yanghui01
阅读(236)
评论(0)
推荐(0)
上一页
1
···
19
20
21
22
23
24
25
26
27
···
49
下一页
公告