一.熟悉jupyter notebook
1. code状态to markdown状态:esc+M
2. markdown状态 to code状态:esc + Y
3. 运行程序快捷键:ctr + enter
4. 更多内容查看help
1. Code status to markdown status: esc+M
2. Markdown status to code status: esc + Y
3. Run program shortcut key: ctr + enter
4. See help for more content
二.安装扩展库的方法
1. pip在线安装,pip install(命令提示符环境)
2. pip离线安装:pip install扩展库名称
镜像网址:
(https://www.lfd.uci.edu/~gohlke/pythonlibs/)
3. exe安装,不是所有拓展库都支持
4. conda在线安装
(注:若机器上安装多个python开发环境,在一个环境下安装的扩展库在另一环境下无法使用)
1. Pip online installation, pip install (command prompt environment)
2. Pip offline installation: pip install extension library name
[MirrorURL](https://www.lfd.uci.edu/~gohlke/pythonlibs/)
3. exe installation, not all extension libraries support
4. Conda online installation
(Note: If multiple python development environments are installed on the machine, the extension library installed in one environment cannot be used in another environment)
扩展库的使用
import命令:import 模块名 [as 别名]
示例1
示例2
示例3
示例4
from命令:from 模块名 import 对象名 [as 别名](速度略快)
示例5
示例6
示例7
三.python常用内置对象
1.python中处理的*一切都是对象*
2. python中有许多内置对象,可直接使用。比如数字、字符串、列表、字典、元组、集合等
1. Everything processed in python is an object*
2. There are many built-in objects in python, which can be used directly. Such as numbers, strings, lists, dictionaries, tuples, sets, etc.
3. 非内置对象需要导入模块才能使用,如正弦函数sin(x),随机数函数random()
4. python中不用声明变量名及其类型,直接赋值即可创建各种类型的对象变量
3. Non-built-in objects need to be imported into modules to be used, such as sine function sin(x), random number function random()
4. In python, there is no need to declare the variable name and its type. You can create various types of object variables by directly assigning values.
示例8
5. python中的变量并不存储值,而是存储值的地址或引用
5. Variables in python do not store values, but addresses or references to store values
示例9
6. python中不同变量赋相同值(仅限于-5到256之间的值),值只存在一份,多个变量指向同一块地址块
6. Assign the same value to different variables in python (limited to values between -5 and 256), there is only one value, and multiple variables point to the same address block
示例10
7. python解释器根据赋值或运算自动推断变量类型,其变量类型可随时变化
7. The python interpreter automatically infers the variable type according to the assignment or operation, and the variable type can change at any time
示例11
8. 定义变量名的注意事项:
a. 变量名必须以字母或下划线开头,但以下划线开头的变量在Python中有特殊含义;
b.变量名中不能有` `以及`()`、`”`、`,`、`\`、`:`、`.`、`?`等等
c.不能使用关键字作变量名
8. Precautions for defining variable names:
a. Variable names must start with a letter or underscore, but variables starting with an underscore have special meaning in Python;
b. Variable names cannot include `` and `()`, `”`, `,`, `\`, `:`, `.`, `?`, etc.
c. Cannot use keywords as variable names
4. 变量名对大小写敏感,如student和Student是不同的变量。
5. 不建议使用系统内置模块名、类型名或函数名以及已导入的模块名及其成员名作变量名
4. Variable names are case sensitive, such as student and student are different variables.
5. It is not recommended to use system built-in module names, type names or function names, and imported module names and their member names as variable names
四.数字
1. python支持任意大数字,取决于内存大小
2. 由于精度问题,实数运算可能存在误差
3. 数字的算术运算求值,会进行类型转换
1. Python supports arbitrarily large numbers, depending on the memory size
2. Due to accuracy issues, real number operations may have errors
3. Numerical arithmetic operation evaluation will carry out type conversion
示例1
4. python 支持复数类型及其运算
4.Python supports complex number types and operations
示例2
参考资料:谷歌翻译
本文由LearningYard学苑原创,如有侵权,请联系删除。