2020年4月6日

python异常处理,草稿

摘要: import tracebackdef calc(a,b): res = a/b return resdef main(): money = input('输入多少钱:') months = input('还几个月:') try: res = calc(int(money),int(months)) 阅读全文

posted @ 2020-04-06 18:08 奥喵 阅读(133) 评论(0) 推荐(0) 编辑

python操作excel

摘要: 1、写import xlwt# book = xlwt.Workbook() #新建一个excel# sheet = book.add_sheet('sheet1') #添加一个sheet页# sheet.write(0,0,'姓名')# sheet.write(0,1,'性别')# sheet.w 阅读全文

posted @ 2020-04-06 16:31 奥喵 阅读(202) 评论(0) 推荐(0) 编辑

python网络编程(requests)

摘要: import json,requestsrequests比较好用,不要用urllib#发送get请求# url = 'http://api.nnzhp.cn/api/user/stu_info?stu_name=小黑马'# req = requests.get(url) #发送get请求# prin 阅读全文

posted @ 2020-04-06 15:41 奥喵 阅读(212) 评论(0) 推荐(0) 编辑

2020年4月5日

python操作数据库(mysql、redis)

摘要: 一、python操作mysql数据库 python3中操作mysql数据需要安装一个第三方模块,pymysql,使用pip install pymysql安装即可。import pymysql# pyoracl # 1、连接上mysql ip 端口号 密码 账号 数据库# 2、建立游标# 3、执行s 阅读全文

posted @ 2020-04-05 21:11 奥喵 阅读(636) 评论(0) 推荐(0) 编辑

2020年4月2日

python(函数、参数类型、递归)草稿

摘要: 递归# 递归 自己调用自己count = 0def test1(): # num = int(input('please enter a number:')) global count count+=1 num = 8 if num % 2 == 0: # 判断输入的数字是不是偶数 pass pri 阅读全文

posted @ 2020-04-02 21:31 奥喵 阅读(181) 评论(0) 推荐(0) 编辑

python(集合)

摘要: 集合 天生去重,无序 s = set() #新增空集合 花括号,类似字典,不过是单个元素,不是key,value的键值对 集合范例:s = {‘1’,‘2’,‘3’} s2 = {'1','2','3','4'}s3 = {'1','2','5'} #集合是无序的,所以没有办法通过下标取值 s2.a 阅读全文

posted @ 2020-04-02 12:30 奥喵 阅读(94) 评论(0) 推荐(0) 编辑

练习,替换txt文档中的信息

摘要: import oswith open('b','a+',encoding= 'utf-8') as f,open('b2.bak','w',encoding= 'utf-8') as f2: f.seek(0) for i in f: new_i = i.replace('一','二') f2.wr 阅读全文

posted @ 2020-04-02 11:05 奥喵 阅读(176) 评论(0) 推荐(0) 编辑

2020年4月1日

练习,循环读取txt文档中a的所在行号

摘要: with open('a.txt','a+') as f: f.seek(0) fr = f.readlines() for i in fr: if i.count('a'): print(fr.index(i)+1) 阅读全文

posted @ 2020-04-01 11:18 奥喵 阅读(212) 评论(0) 推荐(0) 编辑

2019年8月1日

又忘记密码了,真的6

摘要: 又忘记密码了,真的6 阅读全文

posted @ 2019-08-01 15:13 奥喵 阅读(64) 评论(0) 推荐(0) 编辑

2019年5月16日

练习题17

摘要: # 17、 将"wdnwjfwj we hd 9#sdfekfmew 2011"里的数字取出来相加结果为2020a ='wdnwjfwj we hd 9#sdfekfmew 2011'b = a.split(' ')c = int(b[3][0])+int(b[4])print(c) 阅读全文

posted @ 2019-05-16 09:41 奥喵 阅读(93) 评论(0) 推荐(0) 编辑

导航