
python
tianyuan233
这个作者很懒,什么都没留下…
展开
-
RHEL6.5下更新python至2.7版本
RHEL6.5下更新python至2.7版本wget http://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2 #下载tar -xvjf Python-2.7.3.tar.bz2.1 #解压cd Python-2.7.3 mkdir /usr/lo原创 2016-03-15 22:33:27 · 2416 阅读 · 0 评论 -
python使用python-binary-memcached操作memcached
安装bmemcachedgithub地址:https://github.com/jaysonsantos/python-binary-memcachedpip install python-binary-memcached使用实例读取文本中的key并插入memcached方法:set#!/usr/bin env python#VideoInfo0_366...原创 2018-01-19 09:32:31 · 1030 阅读 · 0 评论 -
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UX
win下运行python报错:SyntaxError: (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3: truncated \UXXXXXXXX escape$ "D:/Program Files/Python 3.5/python.exe" c:/Users/Administrator/Deskto原创 2018-01-19 10:23:55 · 417 阅读 · 0 评论 -
python小玩具(恶俗古风生成器)
直接粘代码#coding=utf-8from random import choicefrom time import sleeptwo_chars_words = "朱砂 天下 杀伐 人家 韶华 风华 繁华 血染 墨染 白衣 素衣 嫁衣 倾城 孤城 空城 旧城 旧人 伊人 心疼 春风 古琴 无情 迷离 奈何 断弦 焚尽 散乱 陌路 乱世 笑靥 浅笑 明眸 轻叹 烟火 一生 三生 浮生 桃花 梨原创 2018-03-06 16:25:41 · 2007 阅读 · 1 评论 -
pyquery学习笔记
from pyquery import PyQuery as pqdata = '''<ul class="qqq"><li class="1"><a data-moreurl-dict='{"from":"top-nav-click-main","uid":"0"}' href="https://www.douban.com" target="_blank">豆瓣</a></li><li c原创 2018-03-15 22:38:27 · 374 阅读 · 0 评论 -
selenlenium基本用法学习笔记
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support import expected_conditions as EC from sele原创 2018-03-18 16:59:19 · 296 阅读 · 0 评论 -
requsets库学习笔记
import requests from requests.packages import urllib3 response = requests.get(‘http://www.baidu.com‘)print(type(response)) print(response.status_code) print(response.headers) print(response.text)原创 2018-03-12 23:24:10 · 442 阅读 · 0 评论 -
zmail使用企业邮箱
import zmail# 你的邮件内容mail = { 'from':'zty', 'to': 'hahaha', 'subject': 'Success!', # 随便填写 'content': 'This message from zmail!', # 随便填写}# 使用你的邮件账户名和密码登录服务器server = zmail.server(...原创 2018-04-16 10:53:38 · 2421 阅读 · 0 评论 -
python os.path常用方法
import oscurrent_file = os.path.abspath(__file__)tmpl_dir = os.path.dirname(os.path.abspath(__file__))tmpl_dir2 = os.path.join(os.path.dirname(os.path.abspath(__file__)),'tmp')获取当前py文件的绝对路径pri...原创 2018-04-03 17:23:09 · 222 阅读 · 0 评论 -
(unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escap
在读取桌面文件的时候一直报错:(unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3: truncated \UXXXXXXXX escapewith open('C:\Users\Administrator\Desktop\videoname.txt') as rfile:后来发现,在Pytho...原创 2018-05-22 11:06:13 · 2303 阅读 · 0 评论 -
selenium攻占煎蛋妹子图
python 版本 3.5 依赖库:seleniumbeautifulsoap4lxmlrequests使用selenium的原因是 requests库 在实际操作的时候,发现请求返回的内容里面并没有图片的链接:<p> <img src="//img.jandan.net/img/blank.gif" onload="jandan_load_img(this)"/> <span class原创 2017-11-27 14:36:27 · 1738 阅读 · 0 评论 -
迭代器(Iterator)与可迭代的(Iterable)
可以被next()函数调用并不断返回下一个值的对象称为迭代器:Iteratorfrom collections import Iterableisinstance([],Iterable)Out[4]: True#可迭代的from collections import Iteratorisinstance([],Iterator)Out[8]: False#但是并不是一个迭代器总结凡是可原创 2017-10-30 21:52:41 · 347 阅读 · 0 评论 -
python装饰器的使用
python装饰器的使用原创 2016-07-09 22:11:11 · 389 阅读 · 0 评论 -
生成六位验证码python代码
python 生成验证码原创 2016-07-09 22:06:40 · 480 阅读 · 0 评论 -
python面向对象编程学习[1]
根据代码进行学习原创 2016-07-10 21:31:09 · 408 阅读 · 0 评论 -
python 调用数据库
import MySQLdb conn = MySQLdb.connect(host='127.0.0.1',user='root',passwd='19950801',db='rlp') #开门print conn #链接状态cur = conn.cursor() #伸出手recount = cur.execute('select * from us原创 2016-07-11 20:59:15 · 579 阅读 · 0 评论 -
python 时间模块学习
import timeprint time.time() #返回纪元开始的秒数print time.ctime() # 正常的打印时间print time.clock() #clock()返回处理器时钟时间,它的返回值一般用于性能测试与基准测试。因此它们反映了程序的实际运行时间。from time import gmtime,strftimeprint strf原创 2016-07-11 22:36:08 · 432 阅读 · 0 评论 -
Python 爬取网页HTML代码
#/usr/bin/env python#-*- coding:utf-8 -*-import urllib2import sysimport chardetreq = urllib2.Request("http://tycool.top/")content = urllib2.urlopen(req).read()typeEncode = sys.getfilesystemencodin原创 2016-09-29 19:43:24 · 3204 阅读 · 0 评论 -
pipaanzhuang
Centos 6.4 安装Python 2.7 python-pip准备工作下载源码包wget http://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2查看是否安装make工具~#rpm -qa|grep makeautomake-1.11.1-4.el6.noarchmake-3.81-20.el6.x86_64如果没有安装make转载 2016-10-16 21:13:50 · 220 阅读 · 0 评论 -
ImportError: No module named setuptools 报错
ImportError: No module named setuptools 解决方法在python运行过程中出现如下错误: python错误: 1 ImportError: No module named setuptools 这句错误提示的表面意思是:没有setuptools的模块,说明python缺少这个模块,那我们只要安装这个模块即可解决此问题,下面我们来安装一下: 在命令行下:原创 2017-05-29 16:44:28 · 1175 阅读 · 0 评论 -
菲波那切数列与生成器
先写了一个函数 输出菲波那切数列:def fib1(max): n,a,b = 0,0,1 while n < max: print(b) c = a+b a = b b = c n += 1 return 'done'fib1(7)输出如下:"C:\Program Files\Python35\py原创 2017-10-30 21:42:47 · 386 阅读 · 0 评论 -
Flask下拉列表与数据库同步问题解决记录
刚开始 我的表单是这么写的forms.py:tags = Tag.query.all()class MovieForm(FlaskForm): """电影表单""" tag_id = SelectField( label="标签", validators=[DataRequired("请选择标签")], descripti...原创 2018-05-22 16:35:48 · 3533 阅读 · 0 评论