Python/Ruby
文章平均质量分 76
tastesweet
这个作者很懒,什么都没留下…
展开
-
Python文件拷贝-shutil
import shutilsrcDir= "c:\\"srcFileList=['1.txt','python.txt']dstDir="d:\\"dstFileList=['1.txt','python.txt']srcFile = [(srcDir+file) for file in srcFileList]dstFile = [ (dstDir+file) for file in dstFi原创 2013-06-25 17:31:04 · 558 阅读 · 0 评论 -
定制 bash 命令提示符
Issue: 1. VM Host的命令提示符: bash-3.2@host$ 期望是: username@host 点击(此处)折叠或打开bash-3.2$ echo $PS1\s-\v\$bash-3.2$ export PS1="\u@\h:\w\$"Comment: 1. \u : username2. \h : hostname3. \w : working dir原创 2013-06-25 17:32:14 · 616 阅读 · 0 评论 -
CSRF verification failed. Request aborted
在django中利用comments功能,发生错误,错误信息如下:Forbidden (403)CSRF verification failed. Request aborted.HelpReason given for failure: CSRF token missing or incorrect. In general, this can occur when there i原创 2013-06-25 17:32:12 · 586 阅读 · 0 评论 -
python smtp模块实例代码
import smtplib, mimetypes from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart from email.mime.image import MIMEImage import osclass smtpclient: por原创 2013-06-25 17:32:00 · 567 阅读 · 0 评论 -
python模块学习 ---- smtplib 邮件发送
原文:http://blog.csdn.net/jgood/article/details/4329532在基于互联网的应用中,程序经常需要自动地发送电子邮件。如:一个网站的注册系统会在用户注册时发送一封邮件来确认注册;当用户忘记登陆密码的时候,通过邮件来取回密码。smtplib模块是python中smtp(简单邮件传输协议)的客户端实现。我们可以使用smtplib模块,轻松的发送电子邮件原创 2013-06-25 17:31:58 · 672 阅读 · 0 评论 -
pythonchallenge 3
挑战地址:http://www.pythonchallenge.com/pc/def/equality.html 管理员在2009年8月13日编辑了该文章文章。 --> -->原创 2013-06-25 17:31:20 · 408 阅读 · 0 评论 -
Python——maketrans和translate方法到底是什么玩意儿
最近在看Python Cookbook,发现无法理解字符串处理的两个方法maketrans, translate,在Python解释器里面查看说明文档也语焉不详,莫名其妙,结合网上看到的一些说明,这里以比较容易理解的方式来解释一下这两个方法,算是对官方文档的一些注解。maketrans和translate是密切相关的两个方法,先看translate的说明 S.translate(ta原创 2013-06-25 17:31:15 · 778 阅读 · 1 评论 -
pythonchallenge 1
挑战地址: http://www.pythonchallenge.com/pc/def/map.html 图片提示: k --> m o --> Q e --> g其实真正的规律就是 所有的字母替换为字母表中顺序的第三个字母,比如字母表: alphabet=[ 'a','b','c','d','e','f','g原创 2013-06-25 17:31:13 · 518 阅读 · 0 评论 -
【python】 xlrd的使用
详细代码: 点击(此处)折叠或打开Demo:1. open a xls file2. read a sheet3. read a cell or row or col4. modify the cell '''import xlrd import os class XlsEngine(): """ The XlsEngine is a demo class for exce原创 2013-06-25 17:32:21 · 834 阅读 · 0 评论 -
Python内置数据类型
DictionaryDictionary适用{}进行数据组织,Dictionary内部数据没有顺序的概念,键值大小写敏感,可以通过键值修改对应的项,也可以通过键值删除对应的键值。实例代码:#DictionaryExam_Dictionary={ 1:2,"2":"nic","2323":3242} #数据类型可以混用#修改DictionaryExam_Dictionary[1]原创 2013-06-25 17:31:06 · 509 阅读 · 0 评论 -
Python_多线程编程
from time import sleep,ctime>>> def loop0(): print( 'start loop 0 at:',ctime() ) sleep(4) print( 'loop0 done at :',ctime()) >>> def loop1(): print('start loop 1 at :',ctime()) sleep(原创 2013-06-25 17:31:01 · 547 阅读 · 0 评论 -
【python】 读取Excel文件并绘制图表
依赖的包:1.xlrd2.matplot3.numpy读取excel文件并绘制图表代码如下: 点击(此处)折叠或打开import matplotlib.pyplot as pltimport numpy as np import xlrdimport osfrom StringIO import StringIO if __name__ == '__main__': data = xlrd原创 2013-06-25 17:32:18 · 2901 阅读 · 0 评论 -
Matlab环境下使用USB2.0摄像头编程
转载:http://www.matlabsky.com/forum-viewthread-tid-893-highlight-%C9%E3%CF%F1%CD%B7.htmlMatlab中的图像获取工具箱给我们提供了必要的函数,我们直接调用就可以了。在这帖中我们主要就是简单的介绍如何使用该工具箱进行对USB2.0摄像头的编程废话不多说,我们开始言归正传了。但是一定记住你必须安装了PC摄像头才原创 2013-06-25 17:32:05 · 734 阅读 · 0 评论 -
创建Python开发环境 eclipse+pydev
1.下载最新的python版本或者喜欢的版本 Normal 0 false false false MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNorm原创 2013-06-25 17:31:55 · 538 阅读 · 0 评论 -
pythonchallenge 2
挑战地址: http://www.pythonchallenge.com/pc/def/ocr.html 打开时, 图片,一本翻开的书:一行字:recognize the characters. maybe they are in the book, but MAYBE they are in the page source. but MAYBE they are in原创 2013-06-25 17:31:18 · 485 阅读 · 0 评论 -
pythonchallenge 0
from urllib import requestcount=range(0,255)text=[]file = open("e:\\1.txt","w")for i in count: webfile="http://www.pythonchallenge.com/pc/def/"+"%d"%i+".html" print("访问"+webfile+"\n") try:原创 2013-06-25 17:31:11 · 707 阅读 · 0 评论 -
PYthon 批量下载网页图片
from urllib import requestimport threadingfrom time import sleep,ctimeflist = [ "http://xxxx.com/upload/d1b69b20.jpg",\ "http://xxxx.com/upload/c9443ddb.jpg",\ "http://xxxx.com/uploa原创 2013-06-25 17:31:08 · 793 阅读 · 1 评论 -
Linux crontab-自动化的任务
常用crontab命令: 1. crontab -l 查看所有的任务列表2. crontab -e 添加任务3. 任务规则: minute hour day month dayofweek command不指定的用 *代替。例如:每天下午三点执行build, 给定时间执行的任务00 3 * * * /home/test/build.s原创 2013-06-25 17:32:25 · 702 阅读 · 0 评论