随笔分类 -  Python

摘要:__format__ 在format(object,format_spec:str), f-string, ''.format()生效 format_spec [[fill]align][sign][#][0][minimumwidth][.precision][type] class Superf 阅读全文
posted @ 2022-10-12 10:22 ascertain 阅读(28) 评论(0) 推荐(0) 编辑
摘要:import time def dubious(): print(f"\033[32;40;7m{'dubious start'}\033[0m") while True: send_value = yield if send_value is None: break commence = time 阅读全文
posted @ 2022-09-19 16:11 ascertain 阅读(26) 评论(0) 推荐(0) 编辑
摘要:def alarm(item: list): match item: case [time, action]: print(f'{time} {action}') case [time, *actions]: for action in actions: print(f'^^ {time} {act 阅读全文
posted @ 2022-08-28 11:36 ascertain 阅读(127) 评论(0) 推荐(0) 编辑
摘要:import pandas as pd df = pd.DataFrame(data={'id': [1, 2, 3], 'name': ['a', 'b', 'c']}) print(df) df.to_excel('z.xlsx') import pandas as pd df = pd.Dat 阅读全文
posted @ 2022-07-30 19:53 ascertain 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2022-06-11 15:02 ascertain 阅读(56) 评论(0) 推荐(0) 编辑
摘要:生产杯子 import time, logging, threading FORMAT = '%(asctime)s %(threadName)s %(thread)d %(message)s' logging.basicConfig(level=logging.INFO, format=FORMA 阅读全文
posted @ 2022-02-24 22:02 ascertain 阅读(91) 评论(0) 推荐(0) 编辑
摘要:import logging FORMAT = '%(asctime)-15s\tThread: %(threadName)s %(thread)d %(message)s' logging.basicConfig(format=FORMAT, level=logging.WARNING, date 阅读全文
posted @ 2022-02-24 19:47 ascertain 阅读(30) 评论(0) 推荐(0) 编辑
摘要:从低位依次打印,并计算位数 n = int(input('number: ')) count = 0 while True: print(n % 10) n = n // 10 count += 1 if n == 0: break print('number of digits: ', count 阅读全文
posted @ 2022-02-13 16:06 ascertain 阅读(38) 评论(0) 推荐(0) 编辑
摘要:import sys, threading, tkinter,time def stop(window): # window.destroy() window.quit() sys.exit(0) window = tkinter.Tk() window.title('invariant!') wi 阅读全文
posted @ 2021-04-23 19:21 ascertain 阅读(124) 评论(0) 推荐(0) 编辑
摘要:json.dumps(data,ensure_ascii=False,indent=4,sort_keys=True,skipkeys=True,separators=(',',': ')) try: b(1,0) except Exception as e: logging.exception(s 阅读全文
posted @ 2021-04-23 18:30 ascertain 阅读(109) 评论(0) 推荐(0) 编辑
摘要:import os, zipfile def deflate(paths, zip_path): z = zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED, allowZip64=True, compresslevel=9) for path i 阅读全文
posted @ 2021-04-22 17:10 ascertain 阅读(59) 评论(0) 推荐(0) 编辑
摘要:paramiko基于SSH连接ssh Server执行操作(SSHClient远程连接,SFTPClient上传下载) pip install paramiko 简单示例 import paramiko ssh = paramiko.SSHClient() # 创建ssh客户端 know_hosts 阅读全文
posted @ 2021-04-16 17:57 ascertain 阅读(97) 评论(0) 推荐(0) 编辑
摘要:os.chmod(path:Union[int,str,bytes,PathLike[str],PathLike[bytes]],mode:int,dir_fd:Optional[int],follow_symlinks:bool) -> Nonemode 采用 0o7777表示法 os.chmod 阅读全文
posted @ 2021-04-13 18:44 ascertain 阅读(110) 评论(0) 推荐(0) 编辑
摘要:import os, time from PyPDF2 import PdfFileReader, PdfFileWriter def get_file_list(path): file_list = [os.path.join(root, filepath) for root, dirs, fil 阅读全文
posted @ 2021-03-16 18:22 ascertain 阅读(277) 评论(0) 推荐(0) 编辑
摘要:import sqlalchemy from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column,Integer,String,Float,Enum,Date from sqlalchemy 阅读全文
posted @ 2020-12-18 01:39 ascertain 阅读(94) 评论(0) 推荐(0) 编辑
摘要:from wsgiref.simple_server import make_server from webob import Response, Request, exc, dec import re, traceback, logging class Dict2Obj(object): def 阅读全文
posted @ 2020-12-13 23:28 ascertain 阅读(107) 评论(0) 推荐(0) 编辑
摘要:import pymysql from pymysql.cursors import DictCursor # class Field: # def __init__(self,name,column=None,chief=False,unique=False,index=False,nullabl 阅读全文
posted @ 2020-12-13 23:25 ascertain 阅读(114) 评论(0) 推荐(0) 编辑
摘要:import pymysql from pymysql.cursors import DictCursor from queue import Queue import threading class Pool: def __init__(self,size,*args,**kwargs): sel 阅读全文
posted @ 2020-12-13 23:23 ascertain 阅读(393) 评论(0) 推荐(0) 编辑
摘要:class Genre: def __init__(self,title,mold): self.title=title self.mold=mold def __get__(self,instance,owner): print('__get__',self,instance,owner) ret 阅读全文
posted @ 2020-11-28 19:55 ascertain 阅读(98) 评论(0) 推荐(0) 编辑
摘要:import logging,traceback,sys logging.basicConfig(level=logging.WARNING,filename='c:/uiop.txt',filemode='a', format='%(lineno)s %(pathname)s %(asctime) 阅读全文
posted @ 2020-11-12 17:04 ascertain 阅读(101) 评论(0) 推荐(0) 编辑

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