python知识体系回顾

字符串的切片 遵循左开右闭规则

例如 :>>>program = 'I am a python programmer'

progarm[:]

progam[:5]

program[6]

program[4:9]

program[ -10:-1]

program [ -4: ]

program[ -1]

字符串的合并,修改,删除

数字和运算符   整数 、浮点数、复数、布尔 (0,1)   +  -   *  /    //     %     ** 

and   or    not                             进制 0b  0x  0o   0d   

&        |        ^       

~    (按位反转运算符)    将二进制数+1之后乘以-1     >>> ~0b00110101    -(53+1) 

<<  (m<<x)  把m的二进制全部左移x位,高位在超出操作系统支持位数时,丢弃,不超出时左移,低位补0。x为需要移动的位数

>>  右移运算符  (m>>x) 把m的二进制全部右移x位,低位丢弃,高位补0.

比较运算符   ==     !=     >      <      >=   <=

赋值运算符   =      +=      -=     *=      /=       %=     **=     //=     <<=    >>=    &=   |=    ^=    

类型转换

if 条件分支

while循环    循环嵌套

for <variable>  in <sequence>:

break    continue

成员运算符    in    not  in 

身份运算符   is   not  is  

运算符比较级

列表 [ ] 列表是可变的序列,也是一种可以存储各个数据类型的集合,[ , ] 表示列表的开始和结束

列表的操作  .append()  .clear()   .copy   .count()   .extennd   .index()    .insert()    .pop()  .remove()

.reverse()   .sort()    del() 函数

元组,是不可变的序列,也是一种可以储存各种数据类型的集合

方法名称方法功能描述
count统计
index返回指定元素的下标

函数名称函数功能
len
max
tuple将列标转换为元组
type返回对象类型
del
del
min

字典,是可变的无序集合,同时是一种以键值对为基本元素的可以储存各种数据类型的集合,

用{ ,}表示元素之间的分离

键值对,由key和value组成,可以更加独立而紧密地表示两者之间的关系

方法名称功能描述
clear
copy
fromkeys使用给定的键建立新的字典
get
items字典遍历
keys
pop
popitem
setdfault
update
values

字典嵌套  字典嵌套字典   列表嵌套字典   字典嵌套列表

python自带函数

print()    help()   type()  del()   len()   id()   max()   abs()     自定义函数

函数目的:把相同的代码单独提炼出来,独立实现一个功能,供需求的代码调用

def 函数名([参数]):

        函数体

        [ return 返回值]

函数可以有参数,也可以没有参数。大多数函数是有参数的,del(x),x为需要删除的对象,这里参数传递对象是简单数据

def factor_no_para():
    i=1
    nums=10
    print("%d的因数是:"%(nums))
    while i <= nums:
        if nums%i ==0:
            print("%d"%(i))
           i+=1
factor_n0_para()
tt=type(factor_no_pqra)
print(tt)
def find_factor(nums):
    i=1
    str = ''
    print('%d的因数是:'%(nums))
    while i<=nums:
        if nums%i==0:
            str=str+''+str(i)
        i+=1
    print(str1)
num2_L = [10,15,18,25]
i = 0
num_len = len (num2_L)
while i<num_len:
    find_factor(num2_L[i])
    i+=1

把函数放到模块中

调用函数模块

函数与变量作用域     全局变量   与   局部变量

global关键字只能读取全局变量的值

闭包

递归: 一种通过重复将问题分解为同类子问题而解决问题的方法

面向对象    类    私有    继承   方法

python  标准库   

datetime   math    random   os    sys time   

异常  

捕捉异常

try:                                                                                                                                                            代码模块 1                                                                                                                                    except:                                                                                                                                                      代码模块 2

带有finally子句处理异常

抛出异常

文件处理

newfile = 'd:\\t1.txt'
b_new_file = open(openfile,'w')
b_new_file.close()
print("%s成功建立!"%(newfile))
newfile = r'd:\t1.txt'
b_rew_file = open(newfile,'w')
t_n = b_new_file.write('I like python!')
B_new_file.close()
print("往文件里写入%d字节内容"%(t_n))
b_new_file = open(newfile,'r')
tt=b_new_file_.read()
print(tt)
b_new_file.close

连续用read()、write()

b_new_file = open(newfile,'r+')
tt = b_new_file.read()
print(tt)
t_n = b_new_file.write('\n三酷猫!^_^')
b_new_file.close()
print("往文件里写入%d字节内容"%(t_n))

JSON

XML

图行用户界面

thinter开发包

tt子模块

tix子模块

scrolledtext子模块

MySQL

测试级打包

web.py

Djanjo框架

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

编程老哥

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值