Python 学习笔记(一)

Python 学习笔记(一)

1. 环境搭建

官网下载安装

(python 编写代码的软件有很多,个人暂时只用python自带的 IDLE 编写,用python shell运行)

2. python初体验
print and input

print(…) -数值
print(’…’) or print(str(…)) -字符
print(" I’m ") or print (’ I’m ’ ) -含缩写的字符
print(’…’+’…’) -字符与字符组合
print(…+…)- 运算符计算

A= input(’…’)- 在…后面输入内容赋值给A

3. python基础讲解
a. python 变量特征+命名规则

变量名可以包含字母(大小写不同含义)、数字、下划线
**(数字不能开头!!) **

b. 注释方法

(1) #单行注释
(2) ‘’’…多行注释 (三个单引号或双引号) …’’'

c. python 中“:”作用

(1) 数组中
[start : end : step]
从start数字开始,到end数字结束,输出接下来的第step个

(2) for and if 语句中
缩进,表明分支语句

d. 学会使用dir()及和help()

dir() 返回模块属性参数
help() 返回对象-函数、模块 帮助信息

e. import 使用

import 路径:引入模块中的函数

f. pep8介绍

4. python数值基本知识
a. python 中数值类型,int, float, bool, e 记法等

int(): 整数型
float():浮点数
bool():布尔型
e记法:科学计数法

b. 算数运算符

+,-,*,/
//(整除),%(取余), ** (幂)

c. 逻辑运算符

and 和-交集
or 或-并集
not 非

d. 成员运算符

in 在指定序列中,找到所找项为true
not in 在指定序列中,未找到所找项为true

e. 身份运算符

is 引用的是同一个对象则返回 True
is not 引用的不是同一个对象则返回结果 True

f. 运算符优先级

图片来自“菜鸟学院”优先级

猜你喜欢

转载自blog.csdn.net/weixin_44691782/article/details/87930350