1.变量命名规则
- 具有描述性,最好英文好一些
- 不可以用特殊字符、空格和数字开头
- 不能用中文
- 保留字符勿用
- 不能以大写字母开头(全大写留给逻辑 常量)
- 驼峰命名法了解一下
2.Python注释
- #注释一行
- ‘’‘三个单引号之间注释多行
- “”"当内部有单引号占用的时候可以用三个双引号
3.用户交互
name = input('your name:')
age = input('your age:')
print(name, 'is', age, 'years old')
4.强制类型转换
a = 3
s = str(a) #原来整型的a变为字符型
#input接收的所有内容都以字符串的形式存储
5.字符串拼接
s = s1 + s2 + s3
s = ''.join([s1, s2, s3])
6.条件语句
if condition1:
command1
else:
command2
或者:
if condition1:
command1
elif condition2:
command2
elif condition3:
command3
else:
command4
7.缩进
判断程序之间的逻辑关系,官方建议的缩进是四个空格