编程语言之 Python 学习 - P0
Python 追求极致的表达力和开发速度,一门解释型语言,通过解释器实时解释代码执行。
安装环境: python
编辑器推荐: neovim vscode
Nvim配置推荐: github
让我们开始吧!
先学变量与数据类型:
变量
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
x = 5
x = "hello"
a, b = 1, 2
a = b = c = 0
SHEN = "Eternity"
|
数据类型表
| 类型 |
例子 |
| int |
x = 5201314 |
| float |
x = 5.20 |
| bool |
x = True / False |
| str |
x = “Eternity” |
| None |
x = None |
| bytes |
x = b”Eternity” |
类型转换
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| x = int("520") x = float("5.20") x = str(520)
x = int("FF", 16) x = int("1010", 2)
x = list("abc") x = tuple([a, b, c])
print(bool(0)) print(bool(1)) print(bool("")) print(bool("hi")) print(bool([])) print(bool(None))
|