吴裕雄 实战python编程(1)】的更多相关文章

import cv2 cv2.namedWindow("frame")cap = cv2.VideoCapture(0)while(cap.isOpened()): ret, img = cap.read() if ret == True: cv2.imshow("frame", img) k = cv2.waitKey(100) if k == ord("z") or k == ord("Z"): cv2.imwrite(&…
import cv2 cv2.namedWindow("ShowImage1")cv2.namedWindow("ShowImage2")image1 = cv2.imread("F:\\pythonBase\pythonex\\ch10\\media\\img01.jpg")#image1 = cv2.imread("media\\img01.jpg", 1)image2 = cv2.imread("F:\\pyt…
import pandas as pd df = pd.DataFrame( {"林大明":[65,92,78,83,70], "陈聪明":[90,72,76,93,56], "黄美丽":[81,85,91,89,77], "熊小娟":[79,53,47,94,80] } )print(df) import pandas as pd datas = [[65,92,78,83,70], [90,72,76,93,56], [8…
import os from win32com import client word = client.gencache.EnsureDispatch('Word.Application')word.Visible = 1word.DisplayAlerts = 0doc = word.Documents.Add()range1 = doc.Range(0,0) #文件起始处range1.InsertAfter("这是测试第一行\n这是测试第二行\n")range1.InsertAft…
import matplotlib.pyplot as plt plt.rcParams['font.sans-serif']=['Simhei']plt.rcParams['axes.unicode_minus']=False listx1 = [1,5,7,9,13,16]listy1 = [15,50,80,40,70,50]plt.bar(listx1, listy1, label="男性")listx2 = [2,6,8,11,14,16]listy2 = [10,40,30…
text = '中华'print(type(text))#<class 'str'>text1 = text.encode('gbk')print(type(text1))#<class 'bytes'>print(text1)#b'\xd6\xd0\xbb\xaa'text2 = text1.decode('gbk')print(type(text2))#<class 'str'>print(text2)#中华 text4= text.encode('utf-8')p…
import hashlib md5 = hashlib.md5()md5.update(b'Test String')print(md5.hexdigest()) import hashlib md5 = hashlib.md5(b'Test String').hexdigest()print(md5) import osimport hashlib import requests # url = "http://opendata.epa.gov.tw/ws/Data/REWXQA/?$ord…
import requests from bs4 import BeautifulSoup url = 'http://www.baidu.com'html = requests.get(url)sp = BeautifulSoup(html.text, 'html.parser')print(sp) html_doc = """<html><head><title>页标题</title></head> <p…
from urllib.parse import urlparse url = 'http://www.pm25x.com/city/beijing.htm'o = urlparse(url)print(o) print("scheme={}".format(o.scheme)) # httpprint("netloc={}".format(o.netloc)) # www.pm25x.comprint("port={}".format(o.po…
import sqlite3 conn = sqlite3.connect('E:\\test.sqlite') # 建立数据库联接cursor = conn.cursor() # 建立 cursor 对象 #新建一个数据表sqlstr='CREATE TABLE IF NOT EXISTS table01 ("num" INTEGER PRIMARY KEY NOT NULL ,"tel" TEXT)'cursor.execute(sqlstr) # 新增一条记录…