Python教程
Python教程:包含了所有代写案例以及部分答案
-
MySQLdb是Python 连接 MySQL 的模块,下面是它一些简单的使用方法: “`python –– coding: utf-8 –– mysqldb import time, MySQLdb 连接 conn=MySQLdb.connect(host=”localhost”,user=”root”,passwd=””,db=”test” … 继续阅读“python MySQLdb 使用方法”
:
-
之前看到有人写过类似的代码,感觉有点累赘,其中登陆那些东西其实可以避免的 我把百度音乐的网页代码稍微分析了一下,如果要求不高,下载普通音质的歌曲是不需要登陆的(当然如果你用浏览器打开下载的话,普通音质也是要求登陆下载的) 看其代码发现,即使你没有登陆,其实下载链接也已经暴露出来了,只是用javascript阻止了你在浏览器中下载, 我下面写了一个下载的demo,顺便测试了一下多进程,批量下载很实用: #!/usr/bin/env python #-*- coding: UTF-8 -*- imp … 继续阅读“python下载百度音乐代码”
:
-
# -*- coding: utf-8 -*- from gevent import monkey monkey.patch_all() from gevent.pool import Pool import urllib2 import re import os all_pic_urls = [] base_url = "http://iconmatrix.sharpmark.net" pic_save_path = ‘./icons’ def get_page_count … 继续阅读“python 下载锤子OS重绘的图标”
:
-
import os,inspect,socket,time,pymysql num = 0 class Mysql: def __init__(self,host,user,password,db): self.cnn = pymysql.connect(host=host,user=user, passwd=password, db=db, charset=’utf8′) self.cur= self.cnn.cursor() def run(self,sql): self.cur.execu … 继续阅读“Python获取系统信息的代码”
:
-
#-*-coding:utf-8-*- #python3.3.5 import urllib.parse,urllib.request,http.cookiejar,io,webbrowser import tkinter as tk from tkinter import * from tkinter.ttk import * from urllib.request import urlopen from PIL import Image, ImageTk global root #设置coo … 继续阅读“python CSDN免积分下载器(已打包)”
:
-
下面的python代码演示线程锁的用法和线程同步 #!/usr/bin/python import threading import time class myThread (threading.Thread): def __init__(self, threadID, name, counter): threading.Thread.__init__(self) self.threadID = threadID self.name = name self.counter = counter d … 继续阅读“python线程同步”
:
-
#Filename: DBcon.py import sqlite3 import time conn=sqlite3.connect(r’D:\Exercise\Python\DB\example.db’) c=conn.cursor() c.execute("Create table if not exists stocks (date text, trans text, symbol text, qty real, price real)") flag=raw_inpu … 继续阅读“python使用sqlite3的简单代码”
:
-
from PIL import Image, ImageFilter, ImageOps img = Image.open(‘C:\\Users\\hengli\\Pictures\\lovewallpaper\\214926-106.jpg’) def dodge(a, b, alpha): return min(int(a*255/(256-b*alpha)), 255) def draw(img, blur=25, alpha=1.0): img1 = img.convert(‘L’) # … 继续阅读“Python3.4图片转换素描”
:
-
python3 默认的是UTF-8格式,但在在用dump写入的时候仍然要注意:如下 import jsondata1 = { "TestId": "testcase001", "Method": "post", "Title": "登录测试", "Desc&qu … 继续阅读“解决python3 json数据包含中文的读写问题”
: