随笔分类 -  python

1
摘要:import pymysql config = { 'host': '127.0.0.1', 'port': 3306, 'user': 'root', 'password': 'root', 'database': 'sys', 'cursorclass': pymysql.cursors.Dic 阅读全文
posted @ 2023-01-19 16:48 OTAKU_nicole 阅读(20) 评论(0) 推荐(0)
摘要:import re stringA = "abcdefghijk" pattern = re.compile(r'd(.+?)h') # 匹配d和h中间的内容 print(re.findall(pattern, stringA)) # ['efg'] stringB = "abcdefg(pytho 阅读全文
posted @ 2022-08-18 17:41 OTAKU_nicole 阅读(340) 评论(0) 推荐(0)
摘要:import requests url = "https://***" payload={} proxies = {"http": "http://127.0.0.1:8080", "https": "http://127.0.0.1:8080"} headers = { 'Cookie': 'Co 阅读全文
posted @ 2022-08-02 10:25 OTAKU_nicole 阅读(1385) 评论(0) 推荐(0)
摘要:import json from websocket._core import create_connection # 安装 websocket-client host = "wss://****" ws = create_connection(host,timeout=3) try: # 发送da 阅读全文
posted @ 2022-07-11 17:49 OTAKU_nicole 阅读(114) 评论(0) 推荐(0)
摘要:import time # 时间戳转日期 timeStamp = 1656399821 # 十位时间戳 timeArray = time.localtime(timeStamp) printDate = time.strftime("%Y-%m-%d %H:%M:%S", timeArray) pr 阅读全文
posted @ 2022-06-28 15:05 OTAKU_nicole 阅读(236) 评论(0) 推荐(0)
摘要:import random import string tempId = ''.join(random.sample(string.digits, 11)) print(tempId) 报错:ValueError: Sample larger than population or is negati 阅读全文
posted @ 2022-06-08 14:33 OTAKU_nicole 阅读(627) 评论(0) 推荐(0)
摘要:import random import string print(string.digits) # 数字 print(string.ascii_letters) # 大小写 print(string.ascii_lowercase) # 小写 print(string.ascii_uppercas 阅读全文
posted @ 2022-05-24 15:53 OTAKU_nicole 阅读(95) 评论(0) 推荐(0)
摘要:回退selenium版本 pip install selenium==3.141.0 阅读全文
posted @ 2022-05-20 19:38 OTAKU_nicole 阅读(747) 评论(0) 推荐(0)
摘要:import datetime today = datetime.date.today() # 周一为第一天 week_start = today - datetime.timedelta(days=today.weekday()) week_end = today + datetime.timed 阅读全文
posted @ 2022-05-12 18:37 OTAKU_nicole 阅读(631) 评论(0) 推荐(0)
摘要:import datetime stamp = datetime.datetime(2021,9,1,15,23,56) print("%Y 4位数年:",stamp.strftime("%Y")) # %Y 4位数年: 2021 print("%y 2位数年:",stamp.strftime("% 阅读全文
posted @ 2021-09-10 16:39 OTAKU_nicole 阅读(740) 评论(0) 推荐(0)
摘要:import datetime datetime.date(2021,12,1) # 2021-12-01 datetime.time(12,23,48,333) # 12:23:48.000333 datetime.datetime(2021,12,1,12,23,48,333) # 2021-1 阅读全文
posted @ 2021-09-09 17:22 OTAKU_nicole 阅读(210) 评论(0) 推荐(0)
摘要:a = {"A":"1"} b = a b.update({"B":"2"}) print("a",a) print("b",b) '''用=时,修改b时,原字典a被修改 a {'A': '1', 'B': '2'} b {'A': '1', 'B': '2'} ''' a = {"A&quo 阅读全文
posted @ 2021-07-16 11:08 OTAKU_nicole 阅读(106) 评论(0) 推荐(0)
摘要:import base64 str_A = "待加密的字符串AABBCC" eStr_A = base64.b64encode(str_A.encode()) print(eStr_A) # b'5b6F5Yqg5a+G55qE5a2X56ym5LiyQUFCQkND' dStr_A = base6 阅读全文
posted @ 2021-07-08 16:09 OTAKU_nicole 阅读(376) 评论(0) 推荐(0)
摘要:base64.b64decode(str_A) 把$替换成+ str_A.replace("$","+") base64.b64decode(str_A) 阅读全文
posted @ 2021-07-08 16:07 OTAKU_nicole 阅读(1760) 评论(0) 推荐(0)
摘要:import openpyxl list_wb = openpyxl.load_workbook('list.xlsx') #打开现有工作表 sheet = list_wb.active print(sheet.max_row) # 获取最大行 print(sheet.max_column) # 获 阅读全文
posted @ 2021-02-08 18:00 OTAKU_nicole 阅读(137) 评论(0) 推荐(0)
摘要:import xlrd from xlutils.copy import copy # 打开Excel wb = xlrd.open_workbook('list.xls') # 打开Excel的sheet,有多种方式,此处选择第一个sheet sheet = wb.sheet_by_index(0 阅读全文
posted @ 2021-02-08 14:26 OTAKU_nicole 阅读(86) 评论(0) 推荐(0)
摘要:from PIL import Image left = 763 top = 863 right = 1258 bottom = 962 im = Image.open("img.jpg") im = im.crop((left, top, right, bottom)) im.save("img_ 阅读全文
posted @ 2021-01-25 11:31 OTAKU_nicole 阅读(169) 评论(0) 推荐(0)
摘要:import requests pic_url = "https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png" r = requests.get(pic_url) with open("1.png", "wb")as f 阅读全文
posted @ 2020-10-15 10:58 OTAKU_nicole 阅读(1548) 评论(0) 推荐(0)
摘要:import optparse def testparam(paramA,paramB,paramC='C'): print('paramA:', paramA) print('paramB:', paramB) print('paramC:', paramC) def main(): parser 阅读全文
posted @ 2020-10-07 20:16 OTAKU_nicole 阅读(109) 评论(0) 推荐(0)
摘要:1、先安装pyinstaller pip install pyinstaller 2、切换到文件目录 cd mypath 3、使用以下命令 pyinstaller -F ***.py 阅读全文
posted @ 2020-05-27 10:01 OTAKU_nicole 阅读(150) 评论(0) 推荐(0)

1