Python iterator:
Iterator=iter (obj)
Iterator.next ()
Python functions:
def function (*args):
A tuple list parameter is passed.
def function (**args):
The dictionary list parameter.
Django Time zone settings: setting.py inside the Time_zone=asian/shanghai
PostgreSQL time zone settings: postgres.conf configuration file Modification Time_zone=asian/shanghai
Python Socket module:
Server-side:
Import socket
S=socket.socket (Socket.af_inet,socket. SOCK_STREAM)
S.bind (' 192.168.1.1 ', 80)
S.listen (1)
While True:
Cs,ca=s.accept ()
Print CS.RECV (1024)
Cs.sendall (' reply ')
Cs.close ()
Client:
Import socket
S=socket.socket (Socket.af_inet,socket. SOCK_STREAM)
S.connect (' 192.168.1.1 ', 80)
S.send (' Hello ')
Print S.RECV (1024)
S.close ()
Python http Library:
Import Httplib
Http=httplib. Httpconnection (' itercast.com ', 80)
Http.request (' GET ', '/ask ')
Print Http.getresponse (). Read ()
Http.close ()
Import URLLIB2 (simpler implementation of HTTP,FTP and other protocols)
Opener=urllib2.build_opener ()
F=opener.open (' Http://itercast.com/ask ')
Print F.read ()
F.close ()
Ping linuxcast.net
Finish.
This article is from the "Blue Fin Dolphin" blog, please be sure to keep this source http://likunheng.blog.51cto.com/9527645/1575509
Getting started with Python sockets and HTTP