随笔分类 -  Python3

摘要:pip3 install websockets 主要用到的API有: websockets.connect() websockets.send() websockets.recv() server.py,用于搭建webscocket服务器,在本地8888端口启动,接收到消息后会在原消息前加上I go 阅读全文
posted @ 2022-09-05 23:02 莫贞俊晗 阅读(1532) 评论(1) 推荐(0) 编辑
摘要:本文包含对数据库、集合以及文档的基本增删改查操作 ###数据库操作 #1、增 use config #如果数据库不存在,则创建并切换到该数据库,存在则直接切换到指定数据库。 #2、查 show dbs #查看所有数据库,相当于Mysql的show databases #空数据库不会显示在列表中比如默 阅读全文
posted @ 2022-08-02 23:34 莫贞俊晗 阅读(285) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/env python # -*- coding:utf-8 -*- import cv2 class SlideCrack(object): def __init__(self, gap, bg): """ init code :param gap: 缺口图片 :param b 阅读全文
posted @ 2022-07-31 23:12 莫贞俊晗 阅读(174) 评论(0) 推荐(0) 编辑
摘要:# -*- coding: utf-8 -*- import io import json from pathlib import Path from PIL import Image import base64 import cv2 import time import requests sess 阅读全文
posted @ 2022-07-31 23:02 莫贞俊晗 阅读(563) 评论(0) 推荐(0) 编辑
摘要:def sync_goods_producer(path): # doc_data = pandas.read_excel(path, skiprows=44, engine='xlrd') doc_data = pandas.read_excel(path,engine='xlrd') doc_d 阅读全文
posted @ 2022-07-22 17:19 莫贞俊晗 阅读(83) 评论(0) 推荐(0) 编辑
摘要:import xlwt import pymongo import pandas as pd import xlsxwriter as xw # 连接mongodb数据库 client = pymongo.MongoClient("localhost") # 连接数据库 db = client["D 阅读全文
posted @ 2022-07-22 11:14 莫贞俊晗 阅读(120) 评论(0) 推荐(0) 编辑
摘要:enumerate()是python的内置函数、适用于python2.x和python3.x enumerate在字典上是枚举、列举的意思 enumerate参数为可遍历/可迭代的对象(如列表、字符串) enumerate多用于在for循环中得到计数,利用它可以同时获得索引和值,即需要index和v 阅读全文
posted @ 2022-07-20 22:17 莫贞俊晗 阅读(5366) 评论(0) 推荐(0) 编辑
摘要:{ "_id" : ObjectId("5e908fa139cfeaaf0b97b57b"), "Name" : "Chris", "Age" : 21 } { "_id" : ObjectId("5e908fa939cfeaaf0b97b57c"), "Name" : "David", "Age" 阅读全文
posted @ 2022-07-20 15:44 莫贞俊晗 阅读(192) 评论(0) 推荐(0) 编辑
摘要:###案例1 item1 = {} gender_areas = [] for ge in gender: # 男性 man = ge.split(":")[0].strip() or '' # print("man",man) # 男性比例 man_percent = ge.split(":")[ 阅读全文
posted @ 2022-07-16 18:30 莫贞俊晗 阅读(388) 评论(0) 推荐(0) 编辑
摘要:urlencode() 传入参数类型:字典 功能:将存入的字典参数编码为URL查询字符串,即转换成以key1=value1&key2=value2的形式 导入:from urllib.parse import urlencode Ps:url单个字符串编码用quote()函数 ###1.url标准符 阅读全文
posted @ 2022-06-08 12:42 莫贞俊晗 阅读(5094) 评论(0) 推荐(0) 编辑
摘要:Object of type ‘ObjectId‘ is not JSON serializable ###解决办法 from bson import json_util json_util.dumps(data) 阅读全文
posted @ 2022-05-24 19:22 莫贞俊晗 阅读(88) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2022-05-12 # @Author : # @Platform: import os filename = 'student.txt' def main(): while True: 阅读全文
posted @ 2022-05-12 20:07 莫贞俊晗 阅读(154) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2022/1/16 # @Author : # @Platform: import hmac import base64 import hashlib from hashlib impor 阅读全文
posted @ 2022-01-16 17:58 莫贞俊晗 阅读(1349) 评论(0) 推荐(2) 编辑
摘要:###1.异常信息内容编辑 # 异常信息发送至钉钉报警 if res.get("msg")=="查询失败": print("查询失败") XiaoTian.send_msg_to_dingding(f'hobby策略{platforms_Chinese[plat]}异常', name='hobby_ 阅读全文
posted @ 2022-01-13 14:00 莫贞俊晗 阅读(145) 评论(0) 推荐(0) 编辑
摘要:用jsonpath,不需要一步一步获取路径,有了jsonpath简单一步到位 import jsonpath JSON.initialState.entities.zvideos[1432841727673970688].video.playlist.hd.playUrl playUrl = jso 阅读全文
posted @ 2021-11-19 14:53 莫贞俊晗 阅读(255) 评论(0) 推荐(0) 编辑
摘要:eval字符串str 转字典dict str = ''' window.__ssr_data = JSON.parse("{\"post_data\":{\"item_id\":\"7000687099049417735\",\"uid\":783275173879271,\"ctime\":162 阅读全文
posted @ 2021-11-04 10:01 莫贞俊晗 阅读(240) 评论(0) 推荐(0) 编辑
摘要:如果遇到参数请求没有返回结果,很可能是参数格式问题,可以用以下方法处理 data=json.dumps(params, separators=()) ###例1 import json json.dumps([1,2,3,{'4': 5, '6': 7}], separators=(',',':') 阅读全文
posted @ 2021-09-10 17:19 莫贞俊晗 阅读(1111) 评论(0) 推荐(0) 编辑
摘要:###1 读取json文件报错 https://blog.csdn.net/qq_32526087/article/details/106317051 json.decoder.JSONDecodeError: Invalid control character at: line 1 column 阅读全文
posted @ 2021-09-08 11:33 莫贞俊晗 阅读(464) 评论(0) 推荐(0) 编辑
摘要:###1.将字符串的时间转换为时间戳 import time a = "2021-08-31 11:00:00" # 将其转换为时间数组 timeArray = time.strptime(a, "%Y-%m-%d %H:%M:%S") # 转换为时间戳 timeStamp = int(time.m 阅读全文
posted @ 2021-08-31 13:36 莫贞俊晗 阅读(1511) 评论(0) 推荐(0) 编辑
摘要:###识别图片链接尺寸大小 # 封面链接 url = "https://ci.xiaohongshu.com/5b8597c2-23ea-36ef-7340-c3ee59da9b3b?imageView2/2/w/1080/format/jpg" response = u.urlopen(url) 阅读全文
posted @ 2021-08-17 17:09 莫贞俊晗 阅读(418) 评论(0) 推荐(0) 编辑

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