随笔分类 -  Python

Python开发
摘要:#!/usr/bin/python3.6# -*- coding: UTF-8 -*-from zipfile import ZipFileimport osimport datetimeimport logging LOG_FORMAT = "%(asctime)s %(name)s %(leve 阅读全文
posted @ 2022-10-28 10:08 人生信条~~ 阅读(33) 评论(0) 推荐(0) 编辑
摘要:from pymysql.connections import Connection#创建连接conn = Connection(host='155.138.214.114',port=3306,user='yunwei',password='123456',database='mysql') #默 阅读全文
posted @ 2022-09-14 08:07 人生信条~~ 阅读(38) 评论(0) 推荐(0) 编辑
摘要:import json, os path = "/don"def list_dir(path, res): for i in os.listdir(path): temp_dir = os.path.join(path, i) if os.path.isdir(temp_dir): temp = { 阅读全文
posted @ 2022-07-27 10:38 人生信条~~ 阅读(348) 评论(0) 推荐(0) 编辑
摘要:1. 在CMD里面输入ipython profile create 2.在 ipython_config.py的文件里面开启三个参数 3. c.Completer.use_jedi = True c.Completer.greedy = True c.Completer.jedi_compute_t 阅读全文
posted @ 2022-06-03 19:20 人生信条~~ 阅读(120) 评论(0) 推荐(0) 编辑
摘要:#匿名函数def isodd(x): return x%2a=isodd(10)print(a)isodd = lambda x: x%2#无参数#func= lambda:3,14#func()#print(a)myadd = lambda x,y:x+yA=myadd(1,2)print(A)m 阅读全文
posted @ 2022-05-28 12:26 人生信条~~ 阅读(26) 评论(0) 推荐(0) 编辑
摘要:#作用域#匿名函数def isodd(x): return x%2a=isodd(10)print(a)isodd = lambda x: x%2#无参数#func= lambda:3,14#func()#print(a)myadd = lambda x,y:x+yA=myadd(1,2)print 阅读全文
posted @ 2022-05-27 12:23 人生信条~~ 阅读(25) 评论(0) 推荐(0) 编辑
摘要:#csv文件:使用纯文本来存储表格数据 并以分隔符进行分隔#1.导入模块 import csv#2.打开文件 创建csv对象# f=open(fname)# csvf=csv.reader(f)#3.for row in csvf: print(row)#4.关闭文件 f.close()# impo 阅读全文
posted @ 2022-05-25 08:05 人生信条~~ 阅读(200) 评论(0) 推荐(0) 编辑
摘要:#文件读取path=r'D:\Python学习\day1\a.txt'f=open(path,encoding='utf-8')print(f)txt=f.read()print(txt)f.close()#文件写入# path=r'D:\Python学习\day1\a.txt'# f=open(p 阅读全文
posted @ 2022-05-24 02:13 人生信条~~ 阅读(33) 评论(0) 推荐(0) 编辑
摘要:eventlist=[]def genEvent(): 'return event' event={} keys = ['时间','地点','事件'] for key in keys: msg = input(f'enter {key}') event.setdefault(key,msg) ret 阅读全文
posted @ 2022-05-23 01:45 人生信条~~ 阅读(28) 评论(0) 推荐(0) 编辑
摘要:#列表解析+判断语句求偶数# print([i for i in range(1,101) if i %2==0])import randommath_report=[random.randint(0,100) for i in range(20)]chinese_report=[random.ra 阅读全文
posted @ 2022-05-22 23:41 人生信条~~ 阅读(35) 评论(0) 推荐(0) 编辑
摘要:#1.统计小写英文字符出现的次数def countchrnum(s): result={} for c in s: if c < 'a' or c > 'z':# 判断字母c < a 或者 c >z continue if c in result: result[c] += 1 else: resu 阅读全文
posted @ 2022-05-22 19:11 人生信条~~ 阅读(178) 评论(0) 推荐(0) 编辑
摘要:#字典详解d={'a':'98','b':'97'}a=dict(x=10,y=20) #创建对象b=((('x',90),'y',100))s1='abc's2='123'print(dict(zip(s1,s2)))print(dict.fromkeys(s1,-1))print(a,b)pri 阅读全文
posted @ 2022-05-22 17:19 人生信条~~ 阅读(28) 评论(0) 推荐(0) 编辑
摘要:#冒泡排序list1=[3,2,4,1,5,0]#外部def bubblesort(l): for end in range(len(list1)-1): #内部两两交换位置 循环,len(list1)-end-1 for index in range(len(list1)-end-1): if l 阅读全文
posted @ 2022-05-22 15:29 人生信条~~ 阅读(19) 评论(0) 推荐(0) 编辑
摘要:#列表切片操作l=list(range(10))print(l)A=sum(l)print(A)object=zip('123','345')for item in object: print(item)#1.插入元素list1=[]list1.append(1)list1.append('1')p 阅读全文
posted @ 2022-05-13 19:02 人生信条~~ 阅读(25) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示