python
dptechma
这个作者很懒,什么都没留下…
展开
-
转义字符
转义字符 意义 ASCII码值(十进制) \a 响铃(BEL) 007 \b 退格(BS) ,将当前位置移到前一列 008 \f 换页(FF),将当前位置移到下页开头 012 \n 换行转载 2013-12-07 09:04:22 · 599 阅读 · 0 评论 -
首发论文-数据安全与计算机安全 - 中国科技论文在线 ####统计######
#encoding = utf-8 import urllib2 import urllib from HTMLParser import * class parselinks(HTMLParser): def __init__(self): self.data=[] self.link=[] self.href=0 sel原创 2014-02-18 12:15:16 · 2905 阅读 · 0 评论 -
下载 显示时间
import time import urllib ISOTIMEFORMAT='%Y-%m-%d %X' print time.localtime() urllib.urlretrieve("http://www.baidu.com","C:\\Python_s\\111") urllib.urlretrieve("http://www.baidu.com","C:\\Python_s\\2原创 2014-01-17 13:48:24 · 581 阅读 · 0 评论 -
修改文件夹名字为内部excel中的某个位置的名字
如果存在多个excel,应该会改为最后读到的excel中的指定位置的名字。这儿没做判断和筛选。 import os import xlrd dir_1='D:\\sample\\0103\\modify_name' for fileName in os.listdir(dir_1): if not os.path.isfile(fileName): #prin原创 2014-01-17 10:06:16 · 741 阅读 · 0 评论 -
统计某个网站内的一些内容,很不完善。大家不要看了,浪费时间
#coding = gb2312 #from HTMLParser import HTMLParser from HTMLParser import * #import HTMLParser import urllib import sys import time import MySQLdb #html_parser = HTMLParser.HTMLParser() def db_ins原创 2014-01-17 10:09:14 · 675 阅读 · 0 评论 -
virustotal提交目录样本
def vt_submit(file): host = "www.virustotal.com" selector = "https://www.virustotal.com/vtapi/v2/file/scan" fields = [("apikey", "22222222222222222222222222222222222222222222222222222")] file_to_send = open(file, "rb").read() files = [(原创 2014-01-24 10:33:30 · 1629 阅读 · 0 评论 -
virustotal.com上的公共接口学习
postfile.py文件 来自官方指示:http://code.activestate.com/recipes/146306/ 下面是对应代码: import httplib, mimetypes def post_multipart(host, selector, fields, files): """ Post fields and files to an http原创 2014-01-24 09:23:40 · 4090 阅读 · 0 评论 -
看一下一段时间内58.com对应的ip会不会变化。
一定要记得文件打开要close掉,不然写入的内容会不成功。 import socket import time hostname='www.58.com' ip = socket.gethostbyname(hostname) for i in range(10000): file_1 = open("ip",'a') #print file_1 file_write原创 2014-01-21 12:19:34 · 884 阅读 · 0 评论 -
简单的文件操作的例子
#!Filename:12.1.py temp="adfasfddasf"; f=file('poem.txt','a'); f.write(temp); f.close(); f=file('poem.txt'); while True: line=f.readline(); if len(line)==0: break; print line; f.close();原创 2013-12-23 11:44:53 · 600 阅读 · 0 评论 -
触发异常,自定义异常的例子。。
#Filename:13.2.py class ShortInputException(Exception): def __init__(self,length,atleast): Exception.__init__(self); self.length=length; self.atleast=atleast; try: s=raw_input('Enter somethi原创 2013-12-23 14:15:49 · 699 阅读 · 0 评论 -
python中支持中文方法
在代码开头加上下面一句即可。 #coding=gbk 参考: http://blog.csdn.net/kernelspirit/article/details/2650696原创 2013-12-23 12:07:44 · 891 阅读 · 0 评论 -
存储器的简单例子
#!Filename:12.2.py import cPickle as p; #shoplistfile = shoplist.data; shoplist = ['apple','mango','carrot']; f = file('shoplistfile','w'); p.dump(shoplist,f); f.close(); del shoplist; f=file('sh原创 2013-12-23 12:04:41 · 770 阅读 · 0 评论 -
按Ctrl-d不会引发EOFError。为何????
按Ctrl-d不会引发EOFError。为何???? #Filename:13.1.py import sys try: s=raw_input('Enter something-->'); except EOFError: print "\nWhy did you do an EOF on me?"; sys.exit(); except: print "\n"; print 'D原创 2013-12-23 13:47:29 · 973 阅读 · 1 评论 -
python三引号
python 三引号的形式用来输入多行文本,也就是说在三引号之间输入的内容将被原样保留,之中的单号和双引号不用转义,其中的不可见字符比如\n和\t都会被保留,这样的好处是你可以替换一些多行的文本。原创 2013-12-07 09:22:00 · 716 阅读 · 0 评论 -
贷款计算
#贷款计算 #百分比 利率 m_rate_basic = 5.9 m_rate_fund = 4.0 #利率优惠 m_multi = 1.1 #m_rate_basic = 6.1 #m_rate_fund = 4 #m_multi = 1 #以元为单位 贷款本金 m_money_basic = 1000000 m_money_fund = 300000 #以年为单位 贷款年数 m_year原创 2015-05-04 17:18:31 · 761 阅读 · 0 评论