第一章 环境搭建前端
python 官网www.python.orgpython
pyhton3.6和python2.7区别linux
python2和python3的区别
源码不统一
重复代码数据库
python2
print 能够不加括号
input 获取到的是你输入什么类型,就是什么类型编程
input() "你收到罚单"
raw_input() == python3 inputwindows
python3
print() 必须加括号
input 获取到的都是字符串网络
打开电脑的终端(黑窗口),输入 python回车进去python解释器,返回的结果入下图:python2.7
在终端中 >>> 输入exit() 以下图!函数
# 就是单行注释
''' 就是多行注释 ''' """ 单一引号 双引号均可以 """
print()
input() #input获取的都是str类型的内容
print(12+34) print((12+34)*2) print(((12+34)*2)*3) a=12+34 b=a*2; c=b*3; print(c)
if 3>2:
if 3>2: else :
if 5>4: elif 4>3: elif 3>2: else:
if 3<5: if 4<5 print("这就是循环")
continue 跳出本次循环,继续下次循环编码
可使用if语句控制循环
number=0 while number<5 number+=1 print(number) if number>5: break
格式化输出条件
name=input("名字:") age=input("年龄:") msg ='姓名:%S,年龄:%i'%(name,int(age)) print(msg)
格式化输出第二种
msg=''' _______________ 姓名:%s 年龄:%d 性别:%s 职业:%s 距离成功还有99%% _______________ '''%('DaiJun',20,'男','程序猿') print(msg)
3.6及以上的python才能够的方法
name=input("名字:") age=input("年龄:") msg=f'姓名:{name},年龄:{age}' print(msg)
256 没有中文
一个字节 8位
中文 2字节 16位
英文 1字节 8位
2个字节 16位
4个字节 32位
英文 1字节 8位
欧洲 2字节 16位
亚洲 3字节 24位
> < <= >= == !=
赋值运算符
+= -= /= //= **= %=
成员运算符
in not in
#and运算 两个都为真 取后面的 #and运算 两个都为假 取前面的 and #or运算 两个都为真 取前面的 #or运算 两个都为假 取后面的 or not
+ - * / ** % //