随笔分类 -  python模块自定义

摘要:思路和方案1类似,但是采用http发现速率只有10M 发现FTP能到60M,后发现更慢只有4M 3.下载手段采用ftp实现 阅读全文
posted @ 2021-11-07 08:28 该显示昵称已被使用了 阅读(58) 评论(0) 推荐(0)
摘要:serial和deque模块 import sys import time import re from collections import deque try: import serial.tools.list_ports PYSERIAL_INSTALLED = True except Imp 阅读全文
posted @ 2021-09-15 15:14 该显示昵称已被使用了 阅读(150) 评论(0) 推荐(0)
摘要:import serial import sys from time import sleep import time TELNET_RETURN = "\n" try: ser = serial.Serial("COM11", 115200,timeout=0, parity=serial.PAR 阅读全文
posted @ 2021-09-13 10:52 该显示昵称已被使用了 阅读(126) 评论(0) 推荐(0)
摘要:textfsm # py from textfsm import TextFSM output = ''' N7K# show vlan VLAN Name Status Ports 1 default active Eth1/1, Eth1/2, Eth1/3 Eth1/5, Eth1/6, Et 阅读全文
posted @ 2021-09-10 14:11 该显示昵称已被使用了 阅读(63) 评论(0) 推荐(0)
摘要:def open_telnet_connection(ip_address, port=3000): socket.setdefaulttimeout(3) try: session = telnetlib.Telnet(ip_address, int(port)) except (Connecti 阅读全文
posted @ 2021-09-10 13:57 该显示昵称已被使用了 阅读(110) 评论(0) 推荐(0)
摘要:版本1 # -*- coding: utf-8 -*- import time import paramiko import sys import re from tenacity import retry, stop_after_attempt, wait_fixed import functoo 阅读全文
posted @ 2021-08-16 11:02 该显示昵称已被使用了 阅读(351) 评论(0) 推荐(0)
摘要:带参数装饰器 def get_decorator(errors=(Exception, ), default_value=''): def decorator(func): def new_func(*args, **kwargs): try: return func(*args, **kwargs 阅读全文
posted @ 2021-07-27 14:50 该显示昵称已被使用了 阅读(74) 评论(0) 推荐(0)
摘要:smbclient方法 def check_smb_img(): smbclient.register_session("1.1.1.1", username="name", password="password") img_path = smbclient.listdir(r"\\1.1.1.1\ 阅读全文
posted @ 2021-07-13 17:35 该显示昵称已被使用了 阅读(544) 评论(0) 推荐(0)
摘要:from flask import Flask import pandas as pd app = Flask(__name__) @app.route('/') def show_excel(): df = pd.read_excel("./学生信息表.xlsx") table_html = df 阅读全文
posted @ 2021-05-31 11:29 该显示昵称已被使用了 阅读(381) 评论(0) 推荐(0)
摘要:https://zhuanlan.zhihu.com/p/78329319 https://www.cnblogs.com/miniren/p/5091744.html Python有三种方法解析XML,分别是SAX、DOM和ElementTree: SAX:Python 标准库包含 SAX 解析器 阅读全文
posted @ 2021-05-28 17:27 该显示昵称已被使用了 阅读(277) 评论(0) 推荐(0)
摘要:# 1 import inspect def fun1(): name = inspect.stack()[1][3] print ('%s Invoked me!'%name) def a(): fun1() a() # 2 import traceback def fun2(): name = 阅读全文
posted @ 2021-05-17 16:35 该显示昵称已被使用了 阅读(163) 评论(0) 推荐(0)
摘要:普通方法 # 预期结果 expected = {'username':'kaishui'} # 实际结果 result={ 'code': 1 , 'username':'kaishui', 'token':'ihbedvbwejhvkjvberkjvbkjgkesjvbbje' } def ass 阅读全文
posted @ 2021-05-10 20:06 该显示昵称已被使用了 阅读(380) 评论(0) 推荐(0)
摘要:需要将list以字符串的形式输出,但是list中有不是字符串的情况 ls1 = [1,'ab','cd'] ls2 = [str(i) for i in ls1] # 方法1 ls3 = map(lambda i:str(i), ls1) # 方法2 str_1 = ''.join(ls2) str 阅读全文
posted @ 2021-04-16 16:29 该显示昵称已被使用了 阅读(260) 评论(0) 推荐(0)
摘要:import os import sys JYTHON = sys.platform.startswith('java') IRONPYTHON = sys.platform == 'cli' PYPY = 'PyPy' in sys.version PYTHON = not (JYTHON or 阅读全文
posted @ 2021-04-15 10:56 该显示昵称已被使用了 阅读(71) 评论(0) 推荐(0)
摘要:def _split_camel_case(string): tokens = [] token = [] for prev, char, next in zip(' ' + string, string, string[1:] + ' '): print(prev, char, next) if 阅读全文
posted @ 2021-04-13 16:24 该显示昵称已被使用了 阅读(448) 评论(0) 推荐(0)
摘要:import os file_type = ['py', 'html', 'css', 'js', ] def count_code_nums(file): """获取单个文件的行数 """ with open(file, mode='rb') as f: return len(f.readline 阅读全文
posted @ 2021-03-27 08:28 该显示昵称已被使用了 阅读(206) 评论(0) 推荐(0)
摘要:def download_BBU_packet(build_version='vesion_new_0007_008888_000999'): version = [str(int(num)) for num in build_version.split('_')[2:]] file_name= ' 阅读全文
posted @ 2021-03-10 14:45 该显示昵称已被使用了 阅读(81) 评论(0) 推荐(0)
摘要:import socket import glob import logging import logging.handlers import telnetlib import time ############################################### #### LOG 阅读全文
posted @ 2021-03-05 17:50 该显示昵称已被使用了 阅读(34) 评论(0) 推荐(0)
摘要:# 类的定义 class RobotObjectDict(dict): def __getattr__(self, attr): value = self[str(attr).upper()] return RobotObjectDict(value) if isinstance(value, di 阅读全文
posted @ 2021-02-02 18:10 该显示昵称已被使用了 阅读(62) 评论(0) 推荐(0)
摘要:import os def remove_filename(path_dir, start, end): files = [f for f in os.listdir(path_dir) if f.startswith(start) and f.endswith(end)] for file_nam 阅读全文
posted @ 2021-01-24 11:28 该显示昵称已被使用了 阅读(94) 评论(0) 推荐(0)