一、各个语言的认识:
二、pycharm简单的快捷键:
三、python 的注释:
1、单行注释 (#)
2、多行注释 : ''' '''
'''
a = 1 ------- 多行注释
b = 2
'''
=======================================================================================
variable = '''
a = 1 ------- 多行注释
b = 2
'''
print(variable) -------------- 多行注释可以赋值变量并打印
四、输出的关键字 print 特点:
1、print()自动换行:
print()系统默认 end=" \n"
2、print 输出多个变量:
https://blog.csdn.net/qq_16555103/article/details/83625995 ----------- 第三节 ①小节 4标题
五、常见的简化操作与标识符:
1、变量同时交换数据:
数据同时交换 :a,b = b,a
多个赋值
a = b = c = 1
print(a,b,c)
数据同时交换
a = 1
b = 2
a,b = b,a
2、多个变量对应赋值:
a , b , c = 1 , 2 , "first"
print(a,b,c,)
3、 标识符(变量、定义函数名等)的命名规则:
(1) 命名规则
数字、字母 、下划线
(2) 系统关键字:
(3) 关键字查询方法:
import keyword
print(keyword.kwlist)
4、 数据类型的分类:
数字number(int 、float)、字符串str、列表list、元组tuple、字典dict、集合set、布尔值bool(True False)
、None (空)
六、字符串中转义字符(\)的应用:
在print一些有意义的字符时,需要用 \ 将有意义的字符转化为无意义的字符,比如:
问题:
多个单双引号错误:
由于多个 ' 导致 ' '不能匹配造成语法错误,解决方法:
1. 由此可见双引套单引或者单引套双引可以解决
2. 或者利用 \ 将有意义的字符转化为 普通字符
问题,还有其他常见的有意义的符号 \ \n 等 :
实例:
print('n= 123')
print("s1= 'hello,world'")
print('s1= \'hello,world\'')
print("'hello,\\'Adam\\''")
print('\'hello,\\\'Adam\\\'\'')
print('r\'Hello,"Bart"\'')
print('r\'\'\'Hello.\\nLisa!\'\'\'')
七、简介数据类型:
1、数字:
(1)整型 int:
(2)浮点型 float:
一但 整型 运算中有浮点数,结果将转化为浮点数,默认一位小数。
print(isinstance((6 * 5 /4) ,float)) # True
print((6 * 5 /4 * 10) ) # 答案:75.0 一但运算中有浮点数,结果将转化为浮点数,默认一位小数。
(3)复数类型: complex
#定义复数方法一:
a = 2 + 4j
#定义复数方法二:
a = complex(2,4)
2、字符串str :
str 与 int 都是不可变元素,python 中 str 与 数字不能加减
str 可以索引与切片
str(list对象)、str(数字对象)、str(tuple对象)、str(dict对象) ------------ 转化为字符串
https://blog.csdn.net/qq_16555103/article/details/83625995 ------ 字符串操作
3、列表 list :
https://blog.csdn.net/qq_16555103/article/details/83685961 ------- 列表操作
lis1 = ['1',1,'abc','liukang',]
print(lis1)
- list可以切片与索引
① 索引:
lis1 = [1,2,3,4,5,]
print(lis1[2]) #索引
lis1[2] = 7777 #修改元素,list是可变元素
② 切片详情在字符串查询。
4、tuple:
https://blog.csdn.net/qq_16555103/article/details/83690288 --------- 元组操作
tuple 中的 元素不可改变,但是可以包含可变的对象,比如list。
① 元素不可改变
②可变对象元素可以更改内部,不可替换 该可变元素。
5、dict :
https://blog.csdn.net/qq_16555103/article/details/83690428 ------- 字典操作
dict是可变的,key值必须选择不可变类型(int、str、tuple、bool)
dic1 = {True :'回家'}
dic2 = {1:'我'}
dic3 = {'1':'们'}
print(dic1[True])
print(dic2)
print(dic3['1'])
6、bool:
True、False
0 、 [ ]、 ''、 ()、 {} 、None 注意在if语句中的用法,if {}或者[]
bool可以与数字加减:
a = False + 10
print(a) ------------ 计算时将 False 转化为 0, 将True 转化为1
7、集合 set:
https://blog.csdn.net/qq_16555103/article/details/83714705 -------- 集合操作
八、常见的运算符:
1、列举运算符:
2、and 与 or 运算符的优先级:
优先级: not > and > or
print(1 or 5) # 答案 1
print(3 and 4) # 答案 4
九、关键字 in、not in :
https://blog.csdn.net/qq_16555103/article/details/83625995 ---------- 第五节
十、常见的系统函数:
https://blog.csdn.net/qq_16555103/article/details/83653840