自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(32)
  • 收藏
  • 关注

原创 获取网易云音乐歌单-我喜欢的音乐-歌手与其歌曲数量

import osimport pandas as pdimport sqlite3import jsonimport sysfrom collections import defaultdict# %localappdata%/Netease/CloudMusic/Librarydef get_file_path(): dir_path = os.getenv('lo...

2019-10-17 19:46:43 792

原创 Python 区间库 interval

示例1:创建区间&检验左右边界值In [22]: from interval import Interval# 创建实例In [23]: a = Interval(2,5)# 左右边界是均包含在内,为全闭区间In [24]: 2 in aOut[24]: TrueIn [25]: 5 in aOut[25]: True示例2:半闭半开区间&检测闭区间边界...

2019-07-31 17:18:12 4030 3

原创 用Python生成批处理文件,用于修改IP、DNS

原因:管理windows虚拟机,需要修改IP、DNS等直接给出代码import argparseimport os# 获取当前脚本路径current_path = os.path.dirname(os.path.abspath(__file__))# 用于接受命令行参数(ip)parser = argparse.ArgumentParser(description='Proces...

2018-12-19 17:41:11 1743

原创 fake_useragent 实例化对象时报错

import fake_useragent# 实例化对象时报错ua = fake_useragent.UserAgent()socket.timeout: timed outDuring handling of the above exception, another exception occurred:Traceback (most recent call last): ...

2018-12-11 11:16:53 4350 11

原创 Python 系统路径小结

文件夹路径:F:\003 SVN_DEV\project\Spiders包含文件:F:\003 SVN_DEV\project\Spiders\test.py、F:\003 SVN_DEV\project\Spiders\test_headers.txt# test.pyimport osfile_name = 'test_headers.txt'# 获取当前运行文件同目录下的其他文件...

2018-11-14 17:04:50 298

原创 Python 执行系统命令后并获取返回值

使用os.systemimport os, subprocessIn [33]: result = os.system('tasklist')In [34]: print(result)0# 返回0使用os.popenIn [30]: result = os.popen('tasklist')In [31]: result = result.read()In [...

2018-08-29 10:08:40 6396

原创 Python 字典与json数据转换

# 获取字典dictIn [1]: data = {i:ord(i) for i in list('abcde')}In [2]: dataOut[2]: {'a': 97, 'b': 98, 'c': 99, 'd': 100, 'e': 101}In [3]: import json# dict -> jsonIn [5]: json.dumps(data)Out[5...

2018-08-09 21:40:50 461

原创 centos7 yum安装MongoDB

1、配置yum源vim /etc/yum.repos.d/mongodb-org-3.4.repo2、输入一下内容,保存退出[mongodb-org-3.4]name=MongoDB Repositorybaseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/gpgcheck...

2018-07-30 20:16:56 155

原创 python 查看、修改文件属性

In [132]:import os# 查看文件属性In [133]: os.stat('package-lock.json')Out[133]: os.stat_result(st_mode=33206, st_ino=7036874417947173, st_dev=651824810, st_nlink=1, st_uid=0, st_gid=0, st_size=304, st_a...

2018-07-30 00:05:21 12540

原创 python 时间库小结(time & datetime)

导入库import timeimport datetimetime1、使用time,获取当前时间的时间戳In [42]: time.time()Out[42]: 1532874802.02357582、将时间戳转为当前时区的时间元组 struct_timeIn [43]: time.localtime(time.time())Out[43]: time.s...

2018-07-29 23:38:47 584

原创 Python urlencode&urldecode

from urllib import parsetext = '123abc!@#静夜思'# quote与unquote对应编码、解码quote_text = parse.quote(text)print(quote_text)print(parse.unquote(quote_text))data = dict( a = 123, b = 'a...

2018-07-06 15:52:09 1242

原创 Windows IIS 使用批处理脚本自动安装与卸载

安装IIS使用批处理命令自动安装IIS。注:以下代码片段保存为.bat格式即可。IIS6:适用于win server 2003:: ******************* :: * 安装 :: ******************* :Install Cls @echo. && @echo 安装正在进行中... :: 生成 IIS 6.0...

2018-05-18 12:07:55 3249 2

原创 Python logging模块

基本用法# -*- coding: utf-8 -*-import loggingimport sys# 获取logger实例,如果参数为空则返回root loggerlogger = logging.getLogger("AppName")# 指定logger输出格式formatter = logging.Formatter('[%(asctime)s] %(level...

2018-05-18 00:19:57 134

原创 wireshark 过滤方法汇总

wireshark 过滤方法汇总

2018-03-22 11:09:46 626

原创 Linux 定时任务小记(at、crontab)

引言:了解定时任务的初心就是为了能定时签到,然后再顺便学习Linux。操作系统:Centos 7Linux上用于处理定时任务的有两个工具:at、crontab 名称 应用场景 对应服务 at 执行一次 atd crontab 重复执行 cronatd 的启动方式与 at的使用方法启动服务➜ ~ systemc...

2018-03-21 23:52:59 274

原创 PyCharm Python Console 中文输出乱码

如上图所示:PyCharm 默认打开时,python console中如果用到windows下cmd里的命令时,会输出乱码,原因: cmd默认的编码是gbk(代码页:936),而python console 里面的编码是utf-8(代码页:65001),由于编码不一致,所以输出时会出现乱码解决办法: 如下: 1、File-Setting-Search-console-python consol

2017-12-26 23:17:42 20506 25

原创 使用本地cookie缓存,模拟访问

# python3import requestsimport osimport sqlite3from win32crypt import CryptUnprotectData# cookies存放路径cookie_path = os.environ['LOCALAPPDATA'] + r"\Google\Chrome\User Data\Default\Cookies"# 获取cooki

2017-09-28 19:55:50 609

原创 python 便捷命令

启动本地帮助手册文档服务器,可以查看所有帮助手册c:\> pydoc -p 9000启动简易http服务器# Python 2c:\> python -m SimpleHTTPServer# Python 3c:\> python -m http.server

2017-09-06 10:04:34 341

原创 Jupyter Notebook 服务器配置

Jupyter Notebook配置

2017-09-02 20:10:28 309

原创 python 批量升级所有库

import pipfrom subprocess import callfor i in pip.get_installed_distribuitions(): call("pip install -upgrade " + i.project_name, shell=True)如果安装了Anaconda,安装方式如下:# 更新所有第三方库conda update -all# 更新An

2017-08-30 23:40:20 5886 2

原创 socket笔记

创建服务器from socket import *from time import ctime# 设置HOST,PORTHOST = ""PORT = 20000# 设置缓冲区大小BUFSIZE = 1024ADDR = (HOST, PORT)# 创建服务端sockettcpServerSock = socket(AF_INET, SOCK_STREAM)# 绑定到ADDR上t

2017-08-30 23:13:58 208

原创 pyautogui

一、准备文档地址:官方文档 介绍:The purpose of PyAutoGUI is to provide a cross-platform Python module for GUI automation for human beings. The API is designed to be as simple as possible with sensible defaults.

2017-08-17 11:02:42 2164

原创 celery学习记录

启动redis服务# 保存为start_redis.batredis-server.exe redis.windows.conf不废话直接上代码#tasks.pyfrom celery import CeleryBROKERS = 'redis://localhost:6379/0'BACKEND = 'redis://localhost:6379/1'app = Celery('tasks'

2017-08-09 13:59:48 270

原创 python qrcode 生成二维码

第一步:安装qrcode库(python3)pip install qrcode第二步:命令行生成二维码假设当前路径在 d:\practice,直接打开cmd输入以下命令# 查看qr命令帮助d:\practice> qr --helpd:\practice> qr "hello python" > hello_python.png 这里用手机扫描,显示结果为hello python但是如果用单引

2017-07-24 14:38:55 685

原创 HTML-鼠标移动到元素上时高亮文本

onmousemove: 鼠标移动到元素时触发 onmouseleave: 鼠标离开元素时触发#index.html<<head><head> <meta charset="utf-8"> <script type="text/javascript" src="index.js"> </script></head><body> <p class='backg

2017-07-23 12:29:13 9469

原创 web学习记录

# 引入字体<link href="https://fonts.gdgdocs.org/css?family=Lobster" rel="stylesheet" type="text/css"># 引入css<link href="http://cdn.bootcss.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesh

2017-07-01 18:24:17 257

原创 pymongo库学习

参考资料:pymongo官方Tutorial安装pymongopip install pymongo连接(Connection)pymongo有三种连接方式# 方法一:使用默认值>>> from pymongo import MongoClient>>> client = MongoClient()# 方法二:指定IP及端口>>> client = MongoClient('localhos

2017-06-28 20:05:02 358

原创 Python函数参数探索

最近碰到一个问题,就是函数参数类型怎么判断,是否就是我们定义函数时就已经确定了的?def foo(a, b=0, *args, **kwargs): print(a) print(b) print(args) print(kwargs)按照网上资料,普遍的说法位置参数:a默认参数:b接收任意数量位置参数:args接收任意数量关键字参数:kwargs然后我也

2017-06-24 15:11:48 348

原创 Python中调用help()报错:Not enough Memory

系统环境:win7 SP1 Python3.6 最近在ipython中调用help()函数,提示:Not enough Memory[In1]: help(help)Not enough Memory记得以前使用时没有问题的,然后再网上查了一下, http://bugs.python.org/issue19914 For posterity for anyone that finds

2017-06-22 16:59:29 4916

原创 Python 模块与包

最近在自己自定义的包中相互引用文件时遇到不少问题,以前对包的了解不深,只是停留在会简单调用,但是自己构建的时候才发现问题没那么简单,于是便记录梳理一下在查阅资料之前,明确了有以下几个问题:包与模块的区别自定义的包,之间如何导入包与模块我的理解: 包(Package):包含__init__.py的文件夹都可以视为包 模块(Module):以.py结尾的文件都可以视为模块from packa

2017-06-20 15:22:30 333

原创 CMD文件、文件夹操作

创建删除文件夹mkdir/md功能是一样的,可以查看文档 rmdir/rdF:\> mkdir /?F:\> md /?# 可以看出说明文档是一致的F:\> mkdir a b c d # 会在当前目录下创建a、b、c、d四个文件夹F:\> tree # 显示当前目录,以树形结构显示F:.├───a├───b├───c└───dF:\> rmdir a b c d # 删除a、b

2017-06-20 15:13:14 1030

原创 Windows远程登录Linux(SSH)

下载并安装Puttyhttps://the.earth.li/~sgtatham/putty/0.69/w64/putty-64bit-0.69-installer.msi登录录入IP address录入Port,默认22即可Connection type: 默认即可回车 或 点击 Open正常情况会出现如下提示 根据提示输入username, password即可登录成功如果Linux

2017-06-19 14:18:46 413

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除