随笔分类 -  Python

摘要:因为有服务器线上偶发异常,所以需要获取Nginx访问日志重新请求补全数据,这时会借助python获取错误请求的URL,然后重新请求。 具体如下: import time import requests from urllib.parse import urljoin #定义一个集合用于存储已处理的U 阅读全文
posted @ 2024-08-10 22:20 孤锋饮雪 阅读(21) 评论(0) 推荐(0)
摘要:事先准备环境: Ruby:jekyll3默认最新版本需要v2.2.7 RubyGems NodeJS,或其他javaScript运行环境 Python 2.7 命令: rubt-v 查看本机ruby版本 ruby 2.0.0p648 查看的版本不能支持最新的,需要更新ruby,这时就用到RVM(多版 阅读全文
posted @ 2020-11-17 19:07 孤锋饮雪 阅读(144) 评论(0) 推荐(0)
摘要:接触python 一直觉着编译后报错经常没能捕捉显示,每次也只能从头看到尾 恰好在水木社区中看到关于异常捕捉帖子 方法一:捕获所有异常 try: a=b b=c except Exception,ex: print Exception,":",ex 方法二:采用traceback模块查看异常 imp 阅读全文
posted @ 2018-02-08 12:39 孤锋饮雪 阅读(190) 评论(0) 推荐(0)
摘要:今天遇到了个低级问题: EnvironmentError:mysql_config not found 网上谷歌了一圈发现没用,静下来想的时候才发现新电脑没安装Mysql,吐血 后面再去官网上下载Mysql 进行配置的时候,出现 -bash: mysql: command not found 1、先 阅读全文
posted @ 2018-02-07 10:49 孤锋饮雪 阅读(611) 评论(0) 推荐(0)
摘要:# -*- coding: utf-8 -*-import osimport urllibimport urllib2from bs4 import BeautifulSoup headers = { 'Accept': 'text / html, application / xhtml + xml 阅读全文
posted @ 2018-02-06 16:09 孤锋饮雪 阅读(251) 评论(0) 推荐(0)
摘要:requests库 发送请求: 可以处理所有请求类型:get、post、put、Delete、Head、Options r = requests.get(''https://httpbin.org/') r = requests.post('https://httpbin.org/post') r 阅读全文
posted @ 2018-02-01 19:21 孤锋饮雪 阅读(171) 评论(0) 推荐(0)
摘要:Command "d:\progra~2\jetbra~1\testvir\scripts\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\admin\\appdata\\local\\temp\\pip-buil 阅读全文
posted @ 2018-02-01 15:56 孤锋饮雪 阅读(203) 评论(0) 推荐(0)
摘要:本来运行项目:python manage.py runserver 8000 发现运行到结果报错: Error: That port is already in use 首先查看已存在端口号列表: $ ps aux | grep -i manage 然后只需运行$ kill -9 <pid> 图上显 阅读全文
posted @ 2017-12-15 11:37 孤锋饮雪 阅读(9152) 评论(0) 推荐(0)
摘要:#-*- coding:utf-8 -*- import xlwt import urllib import re def getHtml(url): page = urllib.urlopen(url) html = page.read() return html def get_book_message(url): page = urllib.urlope... 阅读全文
posted @ 2017-10-17 16:31 孤锋饮雪 阅读(237) 评论(0) 推荐(0)