随笔分类 - python模块自定义
摘要:def is_hex(word): word= word.lower() for i in range(len(word)): if not( word[i].startswith('0x') or word[i].isdigit() or word[i] in ['a','b','c','d','
阅读全文
摘要:使用smb 下载文件 import smbclient # pip install smbprotocol import zlib import re import os smbclient.register_session("10.x.x.x", username="123", password=
阅读全文
摘要:基本 # 1. 【python字典】转json格式【str】 import json dic = {'a': 1, 'b': 2, 'c': 3} str1 = json.dumps(dic, sort_keys=True, indent=4, separators=(',', ':')) # 有换
阅读全文
摘要:Django应用 #重写函数,返回json class JSONResponse(HttpResponse): """ An HttpResponse that renders its content into JSON. """ def __init__(self, data, **kwargs)
阅读全文
摘要:(数据库)CSV操作 # 从CSV中读取数据 df = pd.read_csv('pandas.csv',encoding = "utf-8",delimiter=",",error_bad_lines=False) # 读取本地CSV文件 df = pd.read_csv("C:/Users/fu
阅读全文
摘要:方法1. def get_all_news(self, response, file): rm_list = [ # r'</', # r'p>', # r'<', ] ret = response.xpath( '//p[not (img)][not (a)][position()>5] | //
阅读全文
摘要:import paramiko class My_ssh: def __init__(self,ip,username,password): self.ip=ip self.username=username self.password =password self.ssh_client = par
阅读全文
摘要:提醒用户使用了废弃的函数 def deprecated(func): """This decorator is used to mark functions as deprecated. It will result in a warning being emitted when the funct
阅读全文
摘要:import datetime import json import requests from exception import AsstException #自定义 from log import logger #自定义 class Messenger(object): def __init__
阅读全文
摘要:随便用用1 import logging # logging.basicConfig(level=logging.ERROR, format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s:%(message)s') logging.
阅读全文
摘要:定义 # -*- coding: utf-8 -*- import os import configparser class Config(object): def __init__(self, config_file='config.ini'): self._path = os.path.join
阅读全文
浙公网安备 33010602011771号