Python 提供了两个基本的 socket 模块:
Socket它提供了标准的BSD Socket API。SocketServer它提供了服务器重心,可以简化网络服务器的开发。
下面讲解下 Socket模块功能。
| import turtle | |
| import math | |
| def lerp(a, b, t): | |
| """Linear interpolation function. returns a when t==0, returns b when t==1 | |
| and linearly interpolates for values inbetween""" | |
| return (a * (1 - t)) + (b * t) | |
| #!/usr/bin/env python | |
| # A simple demonstration of using cairo to shape windows. | |
| # Natan 'whatah' Zohar | |
| import gtk | |
| import math | |
| class ShapedGUI: | |
| def __init__(self): | |
| self.window = gtk.Window() | |
| self.window.show() # We show here so the window gets a border on it by the WM |