#!/usr/bin/env python //指定解释器 #! -*- coding:utf8 -*- //指定编码 (2.7使用 3默认不需要写)
#单行注释
"""
多行注释
"""
判断语句
if 条件:
代码块 //代码块一定要有缩进,一般一个tab或四个空格
else:
代码块
== //比较
input('提示内容:') //等待输入
if基本语句
if 条件:
内部代码块
elif
内部代码块
elif
pass //这条不操作使用pass
else
print('123')
判断奇数偶数
a=13
temp=a%2
if temp==0
print("偶数")
else:
print('奇数')
字符串
“”
‘’
""" """
''' '''
算数
5**4 //4的4次方
39%8 //获取39除8获取余数
39//8 //获取39/8的商
循环
count = 0
while count < 10
print ('ok',time.time())
count = count+1
count = 0
while count < 10
if count == 7:
count = count + 1
continue //continue 终止当前循环,进行下次循环
print (count)
count = count + 1
count = 0
while count < 10
if count == 7:
count = count + 1
break //break 终止所有循环,直接跳出循环
print (count)
count = count + 1
count = count+1 等价于 count += 1