Skip to content

Commit c30b138

Browse files
committed
post: python tricks 01
1 parent c4255fc commit c30b138

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed
File renamed without changes.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
+++
2+
date = '2025-12-15T8:00:00+08:00'
3+
draft = true
4+
title = 'Python Tricks Part 2: Operators, Expressions and Data Manipulation'
5+
tags = ['Python']
6+
+++
7+
8+
## Literals
9+
10+
整数
11+
12+
```Python
13+
04
14+
0b101010 # Binary 二进制
15+
0o52 # Octal 八进制
16+
0x2a # Hexadecimal 十六进制
17+
```
18+
19+
浮点数,内部使用 IEEE 754 双精度存储
20+
21+
```Python
22+
4.2
23+
42.
24+
4.2e+2 # 科学记数法
25+
4.2E2
26+
-4.2e-2
27+
```
28+
29+
数字类型字面量还可以使用 `_` 来方便阅读
30+
31+
```Python
32+
123_456_789
33+
```
34+
35+
## Truth Values
36+
37+
- `true`: 非0数字、任何非空的字符串,列表,元组或字典
38+
- `false`: 0、None、空列表,元组或字典
39+
40+
## Operations Involving Iterables
41+
42+
TODO: 消耗性迭代器

0 commit comments

Comments
 (0)