学习python第二弹

今天我们来讲讲关于python你必须知道的语法 。
第一 ,Python的文件类型 , 分为源代码 , 字节代码 , 优化代码 。 这些代码可以直接运行 , 不需要编码这正是这门语言的特点 。 源代码以py结束 , 可在控制台下运行;字节代码 , 以pyc结束;优化代码以pyo结束 , 需要用命令行工具生成
第二 ,Python的编码规范 , 在这里详细介绍代码缩进与冒号 , 在使用IDE开发工具时 , 编辑器会自动缩进 。 例如
【学习python第二弹】第三 ,变量和常量 。 变量由字母 , 数字 , 或者下划线组成 , 但是首字符只能是字母或者下划线 。
第四 ,变量的赋值 , 记住Python不同于C语言 , 他的变量的赋值不需要声明 , 他的赋值操作即是变量声明和定义的过程 。 一次新的赋值操作就是创建一个新的变量即使名称相同 , 变量的标识并不相同 。 例如:
第五 ,数据类型 。
首先 , 数字 , 包括整形 , 浮点型 , 布尔型 , 不需要提前声明 , Python根据变量的值自动判断 。 如果需要查看变量的类型 , 可以使用type
第六 ,字符串 。 可以使用单引号 , 双引号 , 三引号 。 单引号和双引号的作用是一样的 , 三引号中可以输入单引号 , 双引号 , 或者换行等字符 。 例如
如果要输入特殊字符 , 需要使用转义字符 。 \
Today we're going to talk about the syntax you need to know about Python.First, Python file types, divided into source code, byte code, optimized code. This code can be run directly without coding, which is characteristic of the language. Source code ends with PY, can run under the console; Byte code, ending with PYC; The optimization code ends with PYO and needs to be generated with a command-line toolSecond, Python's coding specification, which details code indenting and colons, is automatically indented by the editor when using IDE development tools. For example,
Third, variables and constants. Variables are composed of letters, Numbers, or underscores, but first characters can only be letters or underscores.Fourth, the assignment of variables. Remember that Unlike C, Python does not need to declare the assignment of variables, and its assignment operation is the process of declaring and defining variables. A new assignment is to create a new variable even though the name is the same, the identifier of the variable is different. Such as:
Fifth, data types.First of all, Numbers, including plastic, floating point, Boolean, do not need to be declared in advance, Python automatically determines according to the value of the variable. If you need to see the type of a variable, use TypeSixth, strings. You can use single quotes, double quotes, triple quotes. Single quotes and double quotes work the same way. You can enter single, double, or newline characters in triple quotes. For example, if you want to enter special characters, you need to use escape characters. \


    推荐阅读