python创建udp服务端和客户端

1.udp服务端server1 from socket import *2 from time import ctime34 HOST = 5 PORT = 88886 BUFSIZ = 10247 ADDR = (HOST, PORT)89 udpSerSock = socket(AF_INET, SOCK_DGRAM)10 udpSerSock.bind(ADDR)1112 while True:13 print(waiting for message…)14

git github 快速入门

本节内容 为什么要用版本控制? 假设你在的公司要上线一个新功能,你们开发团队为实现这个新功能,写了大约5000行代码,上线没2天,就发现这个功能用户并不喜欢,你老板让你去掉这个功能,你怎么办?你说简单

python第三方库 – dateutil

简介扩展并增强 datetime 模块的功能。支持 Python 2.3+。官方文档 :http://labix.org/python-dateutil安装两种方法:easy_install :easy_install python-dateutilpip在线安装 :pip install python-dateutil方法1,parse字符串可以很随意,可以用时间日期的英

python学习笔记十二:类的定义

demo#!/usr/bin/pythonclass Person:name = jimage = 25def say(self):print My name is + self.name + , and age is + str(self.age)p = Person()p.say()print p.name

python学习笔记十一:操作mysql

一、安装MySQL-python# yum install -y MySQL-python二、打开数据库连接#!/usr/bin/pythonimport MySQLdbconn = MySQLdb.connect(user=root,passwd=admin,host=127.0.0.1)conn.select_db(test)cur = conn.cursor()三、操作数据库def insertdb():sql = insert

python学习笔记十:异常

一、语法#!/usr/bin/pythonfilename=hello#try except finally demotry:open(abc.txt)print helloexcept IOError,msg:print the file not existexcept NameError,msg:print hello not definedfinally:print end#throw exceptionif filename == hello:raise Ty

python学习笔记十五:日期时间处理笔记

#-*- coding: utf-8 -*-import datetime#给定日期向后N天的日期def dateadd_day(days):d1 = datetime.datetime.now()d3 = d1 + datetime.timedelta(days)return d3#昨天def getYesterday():today = datetime.date.today()oneday = datetime.timedelta(days=1)

python学习笔记十六:读取JSON文件

读取JSON文件可以用JSON库,示例代码:#coding:utf-8import jsonwith open(msg.json) as jsonfile:json_data = json.load(jsonfile)for key in json_data:val = json_data[key]print key + t + val

python学习笔记十七:base64及md5编码

一、Python Base64编码Python中进行Base64编码和解码要用base64模块,代码示例:#-*- coding: utf-8 -*-import base64str = cnblogsstr64 = base64.b64encode(str)print str64 #Y25ibG9ncw==print base64.b64decode(str64) #cnblogs二、MD5#Python 2.ximport

python统计日志小脚本

日志格式如下:[ 2016-06-28T00:10:33-03:00 ] xxx.xx.xx.xxx /api/index/xxx/ERR: code:400message:params:country:ustoken:uq6euz9dou6aqtk1Python(3)脚本如下:import urllib.requestimport ntpathimport os, sysimport timedef dirList(path):filelist

返回顶部