CS作业代写 程序 代码、金融、统计、物理、数学、EE、论文、essay案例
-
# 将两个字典合并 #!/usr/bin/python def adddict(dict1,dict2): xin = {} for key in dict1.keys(): xin[key] = dict1[key] for key in dict2.keys(): xin[key] = dict2[key] return xin s1 = {1:222,’c’:’d’,’e’:’f’} s2 = {2:333,’g’:’h’,’i’:’j’} print adddict(s1,s2) 标签: … 继续阅读“python 合并字典”
:
-
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将图片转换成黑白效果”
:
-
#!/usr/bin/python3 # 开始学习python print("hello,world") # 条件语句 a, b = 3, 1 if a < b: print(‘a({}) is less than b({})’. format(a,b)) else: print(‘a({}) is great than b({})’. format(a,b)) # ?: 模仿三元表达式 print("foo" if a < b else &q … 继续阅读“python 简单的python入门语法”
:
-
很多场景为了不阻塞,都需要异步回调机制。这是一个简单的例子。 python的多线程异步常用到queue和threading模块 #!/usr/bin/env python # -*- coding: UTF-8 -*- import logging import queue import threading def func_a(a, b): return a + b def func_b(): pass def func_c(a, b, c): return a, b, c # 异步任务队列 … 继续阅读“Python多线程异步任务队列(实例)”
:
-
这是一个简单的网络程序,可以用来扫描指定ip的常用端口 from socket import * tgtHost=raw_input("What is the web address?: ") tgtPorts=raw_input("What are the ports seperated by commas? or would you like to test all?: ") def connScan(tgtHost, tgtPort): try: c … 继续阅读“python端口扫描程序”
:
-
#!/usr/bin/env python import urllib.request from bs4 import BeautifulSoup mylist = [] print(u’豆瓣电影TOP250:\n 序号 \t 影片名\t 评分\t 评价人数\t 评价’) def crawl(url): headers = {‘User-Agent’:’Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.6) Gecko/200912 … 继续阅读“python 批量抓取豆瓣电影TOP250数据”
:
-
# coding:utf-8 """ 有人问如何遍历取得类的子类或实例 黄哥python远程视频培训班 https://github.com/pythonpeixun/article/blob/master/index.md 黄哥python培训试看视频播放地址 https://github.com/pythonpeixun/article/blob/master/python_shiping.md 咨询qq:1465376564 """ … 继续阅读“python 有人问如何遍历取得类的子类或实例”
:
-
#coding=utf-8 import sys reload(sys) sys.setdefaultencoding( "utf-8" ) import urllib2 import re from bs4 import BeautifulSoup import time import socket #返利网ip为fanly_url fanly_path="F:\yaozhi\yaozhi.txt" fanly_url="http://zhid … 继续阅读“python爬取返利网商品信息”
:
-
”’ pg_midi_sound101.py play midi music files (also mp3 files) using pygame tested with Python273/331 and pygame192 by vegaseat ”’ import pygame as pg def play_music(music_file): ”’ stream music with mixer.music module in blocking manner this will … 继续阅读“python通过PyGame播放Midi和Mp3文件”
:
-
#coding:utf-8 import struct codeDict={}#全局字典key=字符,value=数字 encodeDict={} filename=None listForEveryByte=[] class Node: def __init__(self,right=None,left=None,parent=None,weight=0,charcode=None): self.right=right self.left=left self.parent=parent sel … 继续阅读“Python实现的哈夫曼编码”
: