09 python 2020-05-07 10:35 THURSDAY SUNNY 苏州果动
一、Linux基础
- 计算机以及以后我们开发的程序防止的服务器的简单操作
二、Python开发
https://www.cnblogs.com/wupeiqi/articles/5433893.html
作业:
- 程序
- 博客地址(开通博客)
https://www.cnblogs.com
注册
申请博客
登录
我的博客
随笔:所有人在博客中都可以找到的文章
文章:别人找不到,可以通过URL访问
日志:别人找不到,URL也看不到
开发:
开发语言:
高级语言:Python、Java、C#、PHP、GO、ruby、C++... ===> 字节码 加速执行效率
低级语言:C、汇编 ===> 机器码
语言之间对比:
PHP类:适用于写网页,局限性
Python Java:及可以写网页 也可以写后台功能
- Python执行效率低,开发效率高
- Java执行效率高,开发效率低
Python种类:
JPython
IronPython
CPython(默认)
JavaScriptPython
RubyPython
...
pypy:这是用Cpython开发的Python
安装:
Python安装在OS上
执行操作:
写一个文件文件中按照Python的规则写,将文件交给Python软件,读取文件中的内容,然后进行转换和执行,最终获取结果
python软件 ===> python解释器(内存管理)
下载:
Python3:在继续更新
Python2:在继续更新
Window:点点
python2
python3
# 环境变量
Linux:
python2
python3
a、Python基础
- 基础
1、第一句python
- 后缀名可以是任意?
- 导入模块时,如果不是.py文件
===> 以后文件名缀名是.py
2、两种执行方式:
python解释器 py文件路径
python 进入解释器:
实时输入并获取到执行结果
3、解释器路径
#!/usr/bin/env python
4、编码
# -*- coding:utf8 -*-
ascill:8位
& 00000001
unicode:16位+
& 0000000000000001
utf8:能用多少就用多少
Python3 无需关注
Python2 每个文件中只需要出现中文,头部必须加
5、执行一个操作
提醒用户输入:用户和密码
获取用户名和密码,检测:用户名=root 密码root
正确:登录成功
错误登录失败
a、input用法
#!/usr/bin/env python
# -*- coding:utf8 -*-
#永远等待,直到用户输入一个值
name = input('请输入用户名:')
password = input('请输入密码:')
print(name)
print(password)
6、变量定义的规则:
变量名只能是 字母、数字或下划线的任意组合
变量名的第一个字符不能是数字
以下关键字不能声明为变量名
['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'while', 'with', 'yield']
最好不要和python内置的东西重复,Pycharm编程
7、条件语句
a、if基本语句
if 条件:
内部代码块
内部代码块
else:
...
b、if支持嵌套
if 1 == 1:
if 2 == 2:
print('')
print('')
else:
print('')
else:
print('')
c、if elif
inp = input('请输入会员级别:')
if inp == "高级会员":
print('美女')
elif inp == "白金会员":
print('大模')
elif inp == '铂金会员':
print("一线小明星")
else:
print('城管')
print('开始服务...')
补充:
pass 跳过,无意义
if 1 == 1:
pass
else:
print('')
8、基本数据类型
字符串(引号):
name='A'
name="A"
name='''A'''
name="""A"""
加法:
n1 = 'alex'
n2 = 'sb'
n3 = n1 + n2
print(n3)
乘法:
n1 = 'alex'
n2 = n1 * 10
数字:
数字:
a1 = 10
a2 = 10
a3 = a2 - a1
a3 = a2 + a1
a3 = a2 / a1
a3 = a2 * a1
a3 = 2**2
a3 = a2 % a1
inp = 12
temp = inp % 2
if temp == 0:
print('偶数')
else:
print('奇数')
9、循环
import time
while 1 == 1:
print('ok',time.time())
import time
count = 0
while count < 10:
print('ok',time.time())
count = count + 1
10、练习
1、使用while循环输出 1 2 3 4 5 6 8 9 10
num = 1
while num <= 10:
if num == 7:
pass
else:
print(num)
num = num + 1
2、求1-100的所有数的和
num = 1
count = 0
while num <= 100:
count = num + count
num = num + 1
print(count)
3、输出 1-100 内的所有奇数
num = 1
while num <= 100:
temp = num % 2
if temp != 0:
pass
else:
print(num)
num = num + 1
4、输出 1-100 内的所有偶数
num = 1
while num <= 100:
temp = num % 2
if temp != 0:
pass
else:
print(num)
num = num + 1
5、求1-2+3-4+5 ... 99的所有数的和
num = 1
count = 0
while num <= 100:
temp = num % 2
if temp == 0:
count = count - num
else:
count = num + count
num = num + 1
print(count)
6、用户登陆(三次机会重试)
num = 1
opp = 3
while num <=3:
user_name = input('Please your name: ')
user_passwd = input('Please your password: ')
if user_name == 'root' and user_passwd == 'root':
print('Login Success')
break
else:
opp = opp - 1
print("Error")
print("Also",opp,'Opportunity')
num = num + 1
- 基本数据类型
- 函数
- 面向对象
b、网络编程
c、WEB框架
- 用于写网站
d、设计模式 + 算法
e、项目阶段

浙公网安备 33010602011771号