![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
Black-Spider
机会总是留给有准备的人!
展开
-
Python 对象
class Employee: empCount = 0 def __init__(self,name,salary): self.name = name self.salary = salary Employee.empCount += 1 def displayCount(self): print('to原创 2017-08-01 11:46:38 · 221 阅读 · 0 评论 -
Python 图形编辑 Tkinter Button (二)
#coding=utf-8'''5.Button 的宽度与高度'''# width: 宽度# heigth: 高度from Tkinter import *root = Tk()b1 = Button(root, text = '30X1', width = 30, height = 2原创 2017-08-03 15:34:30 · 522 阅读 · 0 评论 -
Python 图形Tkinter Button
#coding=utf-8'''第一个button 例子'''#command:指定时间处理函数from Tkinter import *#定义Button的时间处理函数def helloButton(): print 'hello Button'root = Tk()#通过 command 属性来指定Button的事件处理函数Button(root, te原创 2017-08-03 15:12:32 · 835 阅读 · 0 评论 -
Python 图形界面Tkinter Label 详解
Python 图像界面 Tkinter (非 tkinter 注意大小写)原创 2017-08-03 14:38:11 · 12602 阅读 · 5 评论 -
Python 创建一个 UDP 服务
由于 UDP 服务器不是面向连接的,所以不用像 TCP 服务器那样做那么多设置工作。事实上,并 不用设置什么东西,直接等待进来的连接就好了。ss = socket() #创建一个服务器套接字ss.bind() #绑定服务器套接字inf_loop: #服务器无限循环cs = ss.recvfrom()/ss.sendto() # 对话(接收与发送)ss.close() # 关闭服原创 2017-08-03 09:03:03 · 896 阅读 · 0 评论 -
Python Threading 模块
#coding=utf-8#使用 threading模块#!/usr/bin/env/pythonimport threadingfrom time import sleep,ctimeloops = [4,2]def loop(nloop,nsec): print 'start loop',nloop,'at',ctime() sleep(nsec) pr原创 2017-08-03 08:56:41 · 225 阅读 · 0 评论 -
Python 服务端与客户端 TCP连接
#server.py#coding=utf-8from socket import *from time import ctimeHOST = ''PORT = 10086BUFSIZE = 1024ADDR = (HOST,PORT)tcpSerSock = socket(AF_INET,SOCK_STREAM)tcpSerSock.bind(ADDR)tcpSer原创 2017-08-02 14:35:55 · 774 阅读 · 0 评论 -
Python 常用库
python 常用库我要纠错阅读(4369)收藏赞(2)分享新版预览GUI 图形界面1.wxpython Python下的GUI编程框架,与MFC的架构相似 下载地址:http://wxpython.org/download.php2. PyQt 用于Python的QT开发库 下载地址:http://www.riverbankcomputing.com/software/p原创 2017-08-01 11:53:27 · 352 阅读 · 0 评论 -
Python 线程同步 线程优先级
线程同步如果多个线程共同对某个数据修改,则可能出现不可预料的结果,为了保证数据的正确性,需要对多个线程进行同步。使用Thread对象的Lock和Rlock可以实现简单的线程同步,这两个对象都有acquire方法和release方法,对于那些需要每次只允许一个线程操作的数据,可以将其操作放到acquire和release方法之间。如下:多线程的优势在于可以同时运行多个任务(至少感觉起来是这样)原创 2017-08-01 11:52:34 · 3618 阅读 · 0 评论 -
Python 使用threading 模块创建线程
#coding=utf-8#!/usr/bin/pythonimport threadingimport timeexitFlag = 0class myThread (threading.Thread): #继承父类threading.Thread def __init__(self, threadID, name, counter): threadi原创 2017-08-01 11:51:43 · 342 阅读 · 0 评论 -
Python 多线程 thread
#!/usr/bin/python# -*- coding: UTF-8 -*-import threadimport time# 为线程定义一个函数def print_time( threadName, delay): count = 0 while count < 5: time.sleep(delay) count += 1原创 2017-08-01 11:51:11 · 187 阅读 · 0 评论 -
Python 发送邮件
以下是一个使用Python发送邮件简单的实例:#!/usr/bin/pythonimport smtplibsender = 'from@fromdomain.com'receivers = ['to@todomain.com']message = """From: From Person To: To Person Subject: SMTP e-mail testThi原创 2017-08-01 11:49:56 · 289 阅读 · 0 评论 -
Python 第一个CGI程序
print "Content-type:text/html\r\n\r\n"print ''print ''print 'Hello Word - First CGI Program'print ''print ''print 'Hello Word! This is my first CGI program'print ''print ''原创 2017-08-01 11:48:24 · 339 阅读 · 0 评论 -
Python 正则表达式
import reline = 'Cats are smarter than dogs'matchobj = re.match(r'(.*) are (.*?) .*',line,re.M|re.I)if matchobj: print('match.group() : ',matchobj.group()) print('match.group(1) : ', mat原创 2017-08-01 11:47:39 · 210 阅读 · 0 评论 -
Python 天气预报
# !/usr/bin/env python# coding=utf-8import httplibimport jsonhttpClient = Nonetry: httpClient = httplib.HTTPConnection('api.map.baidu.com', 80, timeout=30) httpClient.request('GET',原创 2017-08-04 10:33:37 · 588 阅读 · 0 评论