Python基础语法,python语法规则,编码Python源码
Python基础语法,python语法规则,编码Python源码
编码
Python源码文件以UTF-8编码 字符串是Unicode编码
# -*- coding: cp-1252 -*-指定源码文件编码方式
标识符
使用字母数字下划线
首字符为大小写字母或下划线
大小写敏感
保留字
>>> import keyword>>> keyword.kwlist[‘False‘, ‘None‘, ‘True‘, ‘and‘, ‘as‘, ‘assert‘, ‘break‘, ‘class‘, ‘continue‘, ‘def‘, ‘del‘, ‘elif‘, ‘else‘, ‘except‘, ‘finally‘, ‘for‘, ‘from‘, ‘global‘, ‘if‘, ‘import‘, ‘in‘, ‘is‘, ‘lambda‘, ‘nonlocal‘, ‘not‘, ‘or‘, ‘pass‘, ‘raise‘, ‘return‘, ‘try‘, ‘while‘, ‘with‘, ‘yield‘]
注释
单行注释:#开头
多行注释:‘‘‘ 或 """
# 注释 ‘‘‘注释注释‘‘‘ """注释注释"""
缩进
缩进来代表代码块而不使用{}和其他语言不同
缩进的空格数可变 但同一个代码块必须缩进相同的空格数
多行语句
#使用反斜杠\实现多行S = 1 + 2 + \ 3#在 [], {}, 或 () 中的多行语句,不需要使用反斜杠(\)Y = [‘S‘, ‘Y‘, ‘Z‘]
Python基础语法
相关内容
- 《Python编程导论第2版》源代码+学习资料参考,,《Pyt
- python学习(11),,函数参数位置参数传入
- python3 pexpect模块,python模块,pexpectimp
- python 求阶乘之和。求1+2!+3!+...+20!的和,python求5的阶乘
- doraemon的python centos的入门,centos7python,## 第十三章 ce
- python配置文件configparser详解,config配置文件,Python中一般
- Python中tkinter中控件的使用(7,Menu顶层菜单栏),tkinter控
- python matplotlib模块——绘制三维图形、三维数据散点图
- CentOS7 下升级Python版本,版本升级,来博客园的第一篇博
- Python绘制五星红旗,什么的五星红旗,# -*- codi
评论关闭