锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产午夜精品久久久,免费日韩精品中文字幕视频在线,国产三区精品http://m.shnenglu.com/bigsml/zh-cnSun, 16 Nov 2025 02:10:17 GMTSun, 16 Nov 2025 02:10:17 GMT60Google 鏄笅涓涓彈瀹寵呭悧? http://m.shnenglu.com/bigsml/archive/2009/02/17/74036.html娉℃場鐗?/dc:creator>娉℃場鐗?/author>Tue, 17 Feb 2009 06:57:00 GMThttp://m.shnenglu.com/bigsml/archive/2009/02/17/74036.htmlhttp://m.shnenglu.com/bigsml/comments/74036.htmlhttp://m.shnenglu.com/bigsml/archive/2009/02/17/74036.html#Feedback1http://m.shnenglu.com/bigsml/comments/commentRss/74036.htmlhttp://m.shnenglu.com/bigsml/services/trackbacks/74036.htmlJohn Borthwick 鍦?Google Next Victim Of Creative Destruction? 涓鏂囦腑闃愯堪浜咥OL 鐨勬浜′互鍙婁駭涓氱殑涓嶆柇寰幆, yahoo, ebay 絳夊凡緇忔垚涓烘妧鏈潻鏂扮殑鍙楀鑰?

闅忕潃鎼滅儲鐨勫瀭鐩村垎鍓? 鎼滅儲甯傚満涔熻緇嗗寲
1. 瑙嗛鎼滅儲鐨勭獊璧? youtube 浠?007.10 鍒?2008.10 鐨勬悳绱㈠闀夸簡114%, 鍗犱簡google 鎼滅儲鐨?6%.
 2. 瀹炴椂娑堟伅鐨勫彂灞? 浠?a >twitter 涓轟唬琛? 甯傚満瀵圭獊鍙戜簨浠剁殑瑕佹眰鐨勫己鐑? 浣垮緱twitter 榪呴熷彂灞? twitter 鐨勬悳绱?http://search.twitter.com/)涓庝紶緇熷紩鎿庝緷璧栧唴瀹圭浉鍏充互鍙婇摼鎺ュ叧緋葷浉姣? 鏇存敞閲嶆椂闂寸殑鐩稿叧鎬?

Gerry campbell 鐨勬枃绔?nbsp;Search is broken – really broken. 鐨勪竴涓浘璇存槑浜嗚繖縐嶈秼鍔?





]]>
Pythong logging 鍒?Logging4cplus 鐨勯傞厤鍣?/title><link>http://m.shnenglu.com/bigsml/archive/2008/12/19/69856.html</link><dc:creator>娉℃場鐗?/dc:creator><author>娉℃場鐗?/author><pubDate>Fri, 19 Dec 2008 10:13:00 GMT</pubDate><guid>http://m.shnenglu.com/bigsml/archive/2008/12/19/69856.html</guid><wfw:comment>http://m.shnenglu.com/bigsml/comments/69856.html</wfw:comment><comments>http://m.shnenglu.com/bigsml/archive/2008/12/19/69856.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.shnenglu.com/bigsml/comments/commentRss/69856.html</wfw:commentRss><trackback:ping>http://m.shnenglu.com/bigsml/services/trackbacks/69856.html</trackback:ping><description><![CDATA[<p>Python 鐨刲ogging 妯″潡鐨凷ocket 鍜?Logging4cplus 鐨?socket 鐨勬牸寮忔槸涓嶄竴鏍風殑, 鐜板疄涓渶瑕佸皢鏃ュ織鍙戦佸埌logging4cplus 鐨勬湇鍔″櫒, 涓嶅緱宸? 鍐欎簡涓?Python logging 妯″潡鍒?logging4cplus鐨凙dapter <br></p> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080"> 1</span> <span style="COLOR: #008000">#</span><span style="COLOR: #008000">!/usr/bin/env python</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080"> 2</span> <span style="COLOR: #008000">#</span><span style="COLOR: #008000">-*- coding: gbk -*-</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080"> 3</span> <span style="COLOR: #008000"></span><span style="COLOR: #0000ff">from</span><span style="COLOR: #000000"> struct </span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> pack, unpack <br></span><span style="COLOR: #008080"> 4</span> <span style="COLOR: #000000"><br></span><span style="COLOR: #008080"> 5</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> BufferPack(object):    <br></span><span style="COLOR: #008080"> 6</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">def</span><span style="COLOR: #000000"> </span><span style="COLOR: #800080">__init__</span><span style="COLOR: #000000">(self):<br></span><span style="COLOR: #008080"> 7</span> <span style="COLOR: #000000">        self.buffer </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #800000">''</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080"> 8</span> <span style="COLOR: #000000">        <br></span><span style="COLOR: #008080"> 9</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">def</span><span style="COLOR: #000000"> addChar(self, s, unsigned</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">False):<br></span><span style="COLOR: #008080">10</span> <span style="COLOR: #000000">        self.buffer </span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000"> pack(unsigned </span><span style="COLOR: #0000ff">and</span><span style="COLOR: #000000"> </span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">>b</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">or</span><span style="COLOR: #000000"> </span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">>c</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">, s )<br></span><span style="COLOR: #008080">11</span> <span style="COLOR: #000000"><br></span><span style="COLOR: #008080">12</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">def</span><span style="COLOR: #000000"> addShort(self, s, unsigned</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">False):<br></span><span style="COLOR: #008080">13</span> <span style="COLOR: #000000">        self.buffer </span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000"> pack(unsigned </span><span style="COLOR: #0000ff">and</span><span style="COLOR: #000000"> </span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">>H</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">or</span><span style="COLOR: #000000"> </span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">>h</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">, s )<br></span><span style="COLOR: #008080">14</span> <span style="COLOR: #000000">    <br></span><span style="COLOR: #008080">15</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">def</span><span style="COLOR: #000000"> addInt(self, s, unsigned</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">False):<br></span><span style="COLOR: #008080">16</span> <span style="COLOR: #000000">        self.buffer </span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000"> pack(unsigned </span><span style="COLOR: #0000ff">and</span><span style="COLOR: #000000"> </span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">>I</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">or</span><span style="COLOR: #000000"> </span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">>i</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">, s )<br></span><span style="COLOR: #008080">17</span> <span style="COLOR: #000000">    <br></span><span style="COLOR: #008080">18</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">def</span><span style="COLOR: #000000"> addLong(self, s, unsigned</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">False):<br></span><span style="COLOR: #008080">19</span> <span style="COLOR: #000000">        self.buffer </span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000"> pack(unsigned </span><span style="COLOR: #0000ff">and</span><span style="COLOR: #000000"> </span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">>L</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">or</span><span style="COLOR: #000000"> </span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">>l</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">, s )<br></span><span style="COLOR: #008080">20</span> <span style="COLOR: #000000">    <br></span><span style="COLOR: #008080">21</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">def</span><span style="COLOR: #000000"> addString(self, s):<br></span><span style="COLOR: #008080">22</span> <span style="COLOR: #000000">        self.addInt( len(s) ) <br></span><span style="COLOR: #008080">23</span> <span style="COLOR: #000000">        self.buffer </span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000"> s <br></span><span style="COLOR: #008080">24</span> <span style="COLOR: #000000">    <br></span><span style="COLOR: #008080">25</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">def</span><span style="COLOR: #000000"> addBuffer(self, s):<br></span><span style="COLOR: #008080">26</span> <span style="COLOR: #000000">        self.buffer </span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000"> s.buffer <br></span><span style="COLOR: #008080">27</span> <span style="COLOR: #000000"><br></span><span style="COLOR: #008080">28</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> BufferUnpack(object):<br></span><span style="COLOR: #008080">29</span> <span style="COLOR: #000000">    <br></span><span style="COLOR: #008080">30</span> <span style="COLOR: #000000">    char_bits     </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> len( pack(</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">>b</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">, 0) ) <br></span><span style="COLOR: #008080">31</span> <span style="COLOR: #000000">    short_bits     </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> len( pack(</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">>H</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">, 0) ) <br></span><span style="COLOR: #008080">32</span> <span style="COLOR: #000000">    int_bits    </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> len( pack(</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">>I</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">, 0) ) <br></span><span style="COLOR: #008080">33</span> <span style="COLOR: #000000">    long_bits     </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> len( pack(</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">>L</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">, 0) )    <br></span><span style="COLOR: #008080">34</span> <span style="COLOR: #000000">    <br></span><span style="COLOR: #008080">35</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">def</span><span style="COLOR: #000000"> </span><span style="COLOR: #800080">__init__</span><span style="COLOR: #000000">(self, buffer):<br></span><span style="COLOR: #008080">36</span> <span style="COLOR: #000000">        self.buffer </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> buffer <br></span><span style="COLOR: #008080">37</span> <span style="COLOR: #000000">        self.pos </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> 0<br></span><span style="COLOR: #008080">38</span> <span style="COLOR: #000000">    <br></span><span style="COLOR: #008080">39</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">def</span><span style="COLOR: #000000"> _read_item(self, unpackstr, len):<br></span><span style="COLOR: #008080">40</span> <span style="COLOR: #000000">        v </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> unpack(unpackstr, self.buffer[self.pos:self.pos</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">len] )<br></span><span style="COLOR: #008080">41</span> <span style="COLOR: #000000">        self.pos </span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000"> len <br></span><span style="COLOR: #008080">42</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> v <br></span><span style="COLOR: #008080">43</span> <span style="COLOR: #000000">    <br></span><span style="COLOR: #008080">44</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">def</span><span style="COLOR: #000000"> readChar(self, unsigned</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">False):<br></span><span style="COLOR: #008080">45</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> self._read_item(unsigned </span><span style="COLOR: #0000ff">and</span><span style="COLOR: #000000"> </span><span style="COLOR: #800000">'</span><span style="COLOR: #800000"><b</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">or</span><span style="COLOR: #000000"> </span><span style="COLOR: #800000">'</span><span style="COLOR: #800000"><c</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">, self.char_bits)<br></span><span style="COLOR: #008080">46</span> <span style="COLOR: #000000">    <br></span><span style="COLOR: #008080">47</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">def</span><span style="COLOR: #000000"> readShort(self, unsigned</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">False):    <br></span><span style="COLOR: #008080">48</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> self._read_item(unsigned </span><span style="COLOR: #0000ff">and</span><span style="COLOR: #000000"> </span><span style="COLOR: #800000">'</span><span style="COLOR: #800000"><H</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">or</span><span style="COLOR: #000000"> </span><span style="COLOR: #800000">'</span><span style="COLOR: #800000"><h</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">, self.short_bits )<br></span><span style="COLOR: #008080">49</span> <span style="COLOR: #000000">        <br></span><span style="COLOR: #008080">50</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">def</span><span style="COLOR: #000000"> readInt(self, unsigned</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">False):<br></span><span style="COLOR: #008080">51</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> self._read_item(unsigned </span><span style="COLOR: #0000ff">and</span><span style="COLOR: #000000"> </span><span style="COLOR: #800000">'</span><span style="COLOR: #800000"><I</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">or</span><span style="COLOR: #000000"> </span><span style="COLOR: #800000">'</span><span style="COLOR: #800000"><i</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">, self.int_bits )<br></span><span style="COLOR: #008080">52</span> <span style="COLOR: #000000">    <br></span><span style="COLOR: #008080">53</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">def</span><span style="COLOR: #000000"> readLong(self, unsigned</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">False):<br></span><span style="COLOR: #008080">54</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> self._read_item(unsigned </span><span style="COLOR: #0000ff">and</span><span style="COLOR: #000000"> </span><span style="COLOR: #800000">'</span><span style="COLOR: #800000"><L</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">or</span><span style="COLOR: #000000"> </span><span style="COLOR: #800000">'</span><span style="COLOR: #800000"><l</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">, self.long_bits )<br></span><span style="COLOR: #008080">55</span> <span style="COLOR: #000000">    <br></span><span style="COLOR: #008080">56</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">def</span><span style="COLOR: #000000"> readString(self):<br></span><span style="COLOR: #008080">57</span> <span style="COLOR: #000000">        len </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> self.readInt()<br></span><span style="COLOR: #008080">58</span> <span style="COLOR: #000000">        v </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> self.buffer[self.pos:self.pos</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">len] <br></span><span style="COLOR: #008080">59</span> <span style="COLOR: #000000">        self.pos </span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000"> len<br></span><span style="COLOR: #008080">60</span> <span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> v <br></span><span style="COLOR: #008080">61</span> <span style="COLOR: #000000"><br></span><span style="COLOR: #008080">62</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">def</span><span style="COLOR: #000000"> PackMessage( record ):<br></span><span style="COLOR: #008080">63</span> <span style="COLOR: #000000">    bp </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> BufferPack()<br></span><span style="COLOR: #008080">64</span> <span style="COLOR: #000000">    bp.addChar(</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">, True) <br></span><span style="COLOR: #008080">65</span> <span style="COLOR: #000000">    bp.addChar(</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">, True) <br></span><span style="COLOR: #008080">66</span> <span style="COLOR: #000000">    <br></span><span style="COLOR: #008080">67</span> <span style="COLOR: #000000">    bp.addString(</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">{log.servername}</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">) <br></span><span style="COLOR: #008080">68</span> <span style="COLOR: #000000">    bp.addString(record.name) <br></span><span style="COLOR: #008080">69</span> <span style="COLOR: #000000">    bp.addInt(record.levelno</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">1000</span><span style="COLOR: #000000">) <br></span><span style="COLOR: #008080">70</span> <span style="COLOR: #000000">    bp.addString(</span><span style="COLOR: #800000">""</span><span style="COLOR: #000000">)<br></span><span style="COLOR: #008080">71</span> <span style="COLOR: #000000">    bp.addString(record.msg)<br></span><span style="COLOR: #008080">72</span> <span style="COLOR: #000000">    bp.addString(str(record.threadName))<br></span><span style="COLOR: #008080">73</span> <span style="COLOR: #000000">    bp.addString(str(record.process))<br></span><span style="COLOR: #008080">74</span> <span style="COLOR: #000000">    bp.addInt( record.created ) <br></span><span style="COLOR: #008080">75</span> <span style="COLOR: #000000">    bp.addInt( record.msecs ) <br></span><span style="COLOR: #008080">76</span> <span style="COLOR: #000000">    bp.addString(record.filename)<br></span><span style="COLOR: #008080">77</span> <span style="COLOR: #000000">    bp.addInt( </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000"> )     <br></span><span style="COLOR: #008080">78</span> <span style="COLOR: #000000">    <br></span><span style="COLOR: #008080">79</span> <span style="COLOR: #000000">    pkg </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> BufferPack()<br></span><span style="COLOR: #008080">80</span> <span style="COLOR: #000000">    pkg.addInt(len(bp.buffer), True) <br></span><span style="COLOR: #008080">81</span> <span style="COLOR: #000000">    pkg.addBuffer( bp ) <br></span><span style="COLOR: #008080">82</span> <span style="COLOR: #000000">    <br></span><span style="COLOR: #008080">83</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> pkg.buffer<br></span><span style="COLOR: #008080">84</span> <span style="COLOR: #000000"><br></span><span style="COLOR: #008080">85</span> <span style="COLOR: #000000"></span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> </span><span style="COLOR: #800080">__name__</span><span style="COLOR: #000000">==</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">__main__</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">:<br></span><span style="COLOR: #008080">86</span> <span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> logging, logging.handlers <br></span><span style="COLOR: #008080">87</span> <span style="COLOR: #000000">    <br></span><span style="COLOR: #008080">88</span> <span style="COLOR: #000000">    logger </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> logging.getLogger()<br></span><span style="COLOR: #008080">89</span> <span style="COLOR: #000000">    logging.handlers.SocketHandler.makePickle </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">lambda</span><span style="COLOR: #000000"> self,rc : PackMessage(rc) <br></span><span style="COLOR: #008080">90</span> <span style="COLOR: #000000">    <br></span><span style="COLOR: #008080">91</span> <span style="COLOR: #000000">    hdlr </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> logging.handlers.SocketHandler(</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">{logserver.ip}</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">8888</span><span style="COLOR: #000000">) <br></span><span style="COLOR: #008080">92</span> <span style="COLOR: #000000">    formatter </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> logging.Formatter(</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">%(asctime)s %(levelname)s %(message)s</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">)<br></span><span style="COLOR: #008080">93</span> <span style="COLOR: #000000">    hdlr.setFormatter(formatter)<br></span><span style="COLOR: #008080">94</span> <span style="COLOR: #000000">    logger.addHandler(hdlr)<br></span><span style="COLOR: #008080">95</span> <span style="COLOR: #000000">    logger.setLevel(logging.NOTSET)<br></span><span style="COLOR: #008080">96</span> <span style="COLOR: #000000">    <br></span><span style="COLOR: #008080">97</span> <span style="COLOR: #000000">    logger.info(</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">hello</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">)</span></div> <br>浣跨敤鐨勬椂鍊?<br>1. 鍦╨ogging 鍒涘緩SocketHandler 鐨勬椂鍊? 闇瑕佷慨鏀筶ogging.handlers.SocketHandler.makePickle 涓烘柟娉?PackMessage <br>logging.handlers.SocketHandler.makePickle = lambda self,rc : PackMessage(rc) <br><br>2. 闇瑕佷慨鏀逛唬鐮佷腑鐨勪袱閮ㄥ垎鍐呭 {log.servername} 鍜?{logserver.ip}<br> <img src ="http://m.shnenglu.com/bigsml/aggbug/69856.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.shnenglu.com/bigsml/" target="_blank">娉℃場鐗?/a> 2008-12-19 18:13 <a href="http://m.shnenglu.com/bigsml/archive/2008/12/19/69856.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>BHO鍩虹http://m.shnenglu.com/bigsml/archive/2008/12/04/68573.html娉℃場鐗?/dc:creator>娉℃場鐗?/author>Thu, 04 Dec 2008 09:26:00 GMThttp://m.shnenglu.com/bigsml/archive/2008/12/04/68573.htmlhttp://m.shnenglu.com/bigsml/comments/68573.htmlhttp://m.shnenglu.com/bigsml/archive/2008/12/04/68573.html#Feedback0http://m.shnenglu.com/bigsml/comments/commentRss/68573.htmlhttp://m.shnenglu.com/bigsml/services/trackbacks/68573.htmlBHO灝辨槸Browser Helper Object(嫻忚鍣ㄨ緟鍔╁璞?

BHO鍏寵仈鍘熺悊 (BHO鍏寵仈鐨勬槸SHDOCVW,涔熷氨鏄涓嶅彧鍏寵仈IE,涓嬮潰鍏ㄩ儴鐢↖E鏉ヨ鏄?
1.IE鐨勭獥鍙f墦寮鏃?鍏堝鎵綡KLM涓嬬殑SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects\ 閲岀殑CLSID,榪欎簺CLSID,閮藉搴旂潃鐩稿簲鐨凚HO鎻掍歡錛岀劧鍚庢牴鎹繖涓狢LSID鍒癏KCR涓嬬殑CLSIDs閲屾壘鍒版鎻掍歡鐨勪俊鎭紝鍖呮嫭鏂囦歡浣嶇疆絳夈?br>2.IE鏍規嵁鎵懼埌鐨凜LSID淇℃伅鍒涘緩 BHO 瀵硅薄,騫朵笖鏌ユ壘 IObjectWithSite 鎺ュ彛. (榪欎釜鎺ュ彛闈炲父綆鍗?鍙湁SetSite鍜孏etSite涓や釜鏂規硶)
3.IE鎶奍WebBrowser2(嫻忚鍣ㄦ彃浠?浼犲埌 BHO 鐨?SetSite 鏂規硶錛岀敤鎴峰湪姝ゆ柟娉曚腑鍙寕杞借嚜宸辯殑浜嬩歡澶勭悊鏂規硶銆?br>4.紿楀彛鍏抽棴鏃?IE鎶?null 浼犲埌 BHO 鐨?SetSite 鏂規硶錛屾鏂規硶鐢ㄦ潵鍘繪帀鎸傝澆鐨勪簨浠跺鐞嗘柟娉曘?/p>

緙栧啓BHO嫻佺▼
1.鍒涘緩IObjectWithSite鏄懼紡鎺ュ彛錛屽垱寤?COM 綾誨瀷錛屽疄鐜扮戶鎵縄ObjectWithSite鎺ュ彛
2.瀹炵幇姝ゆ帴鍙e茍鍦⊿etSite鏂規硶閲屽姞涓婃墍瑕佹寕杞界殑浜嬩歡
3.澶勭悊浜嬩歡
4.娉ㄥ唽姝HO鍒版敞鍐岃〃涓璈KLM涓嬬殑Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Browser Helper Objects;(HKCR涓嬬殑CLSIDs鏄牴鎹笂闈㈢殑璺緞鑷姩娉ㄥ唽鐨?
5銆?net 涓嬮』璁劇疆姝HO欏圭洰鐨?閰嶇疆灞炴>鐢熸垚 涓負Interop娉ㄥ唽涓篢rue錛岃繖鏍鋒墠鑳藉皢.net 綾誨簱鏂囦歡娉ㄥ唽鍒癈OM

鍒犻櫎BHO
鎵撳紑娉ㄥ唽琛ㄩ」鍒?HKLM涓嬬殑Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Browser Helper Objects 鍙互鐪嬪埌涓嬮潰鏈変竴浜汣LSID鍊?榪欎簺鍊煎搴旂浉鍏崇殑鎻掍歡,鐐瑰嚮鍙互鍦ㄩ粯璁ゅ煎悗鐪嬪埌鐩稿叧鎻掍歡鐨勫悕縐?鍙互澶嶅埗鐩稿叧CLSID鍒版敞鍐岃〃涓悳绱㈢浉鍏矯LSID,鎵懼埌鍚庢墦寮InprocServer32鍙互鐪嬪埌鐩稿叧鏂囦歡鐨勮礬寰?鑷充簬DLL鏂囦歡絳夊彲浠ョ敤UEDIT32.exe宸ュ叿鎵撳紑鏌ョ湅鍏蜂綋淇℃伅,褰撶劧涔熷彲浠ョ敤淇敼紼嬪簭綾葷殑eXeScope.exe鐮旂┒涓涓?
璇鋒牴鎹叿浣撴儏鍐靛垹闄ょ浉鍏抽敭鍊煎拰鐩稿叧鏂囦歡!

REF:
BHO 鐨勭紪鍐?nbsp;
VCKBase 鍏充簬IE 緙栫▼鏂囨。涓績
C++涓嬌鐢˙HO鏉ュ睆钄界壒瀹氱綉绔?/a>
嫻忚鍣ㄩ泦鎴愭暀瀛?鑷畾涔夋祻瑙堝櫒



]]>
36 steps to success as technical leadhttp://m.shnenglu.com/bigsml/archive/2008/10/29/65481.html娉℃場鐗?/dc:creator>娉℃場鐗?/author>Wed, 29 Oct 2008 13:45:00 GMThttp://m.shnenglu.com/bigsml/archive/2008/10/29/65481.htmlhttp://m.shnenglu.com/bigsml/comments/65481.htmlhttp://m.shnenglu.com/bigsml/archive/2008/10/29/65481.html#Feedback0http://m.shnenglu.com/bigsml/comments/commentRss/65481.htmlhttp://m.shnenglu.com/bigsml/services/trackbacks/65481.htmlzz http://littletutorials.com/2008/07/07/success-as-technical-lead/ 
鍒嗕負3涓儴鍒?
Set yourself up for success
Build your relationship with the team
Build your relationship with the management and business people

Set yourself up for success

1. Define early on what success means for you, the team and the business

You have to have a clear idea of what you want. You also have to understand what team members and the management want. You also have to be aware that what people really want, what they say the want and sometimes even what they think they want are very different things. Try to be very honest at least with yourself. Success has different definitions for different people. If there is a big disconnect between these definitions you have a problem before you start.

2. Believe in the project: idea, architecture, time, team

You cannot have any kind of success if you are convinced you lead a team of morons to implement a stupid idea using the wrong architecture in a ridiculously short time. You have to really believe in the project to have a chance to success. This does not mean lie to yourself. It means do whatever you can to understand your concerns and work on them with the management. As for the architecture, it is best if you have a heavy word or if you are the architect.

3. Understand the domain, the business requirements and the technical challenges

You should be an expert in the technologies used for implementation. You also have to become very knowledgeable in the problem domain and the business case. This will help you understand the business decisions dropped on your head from upstairs and also will help you stand a chance at negotiating them.

4. Know your team: strengths, weaknesses, ambitions and personalities

Software is created by people. Your job as a “tech lead” is to support them in doing that, both from a technical point of view and at a human level. You want to lead a team of motivated and enthusiastic people. But each person gets motivated by different things.

5. Have a plan as a result of a planning activity

“Plans are useless but planning is essential” - (Dwight D Eisenhower, US President, general 1890-1969). Planning will make you think about the problems you face in detail. Also keep in mind that “a plan is just a list of things that ain’t gonna happen” - (Benicio Del Torro in “The Way of the Gun”).

6. Be part in the design of everything

This does not mean do the whole design. You want to empower team members. But your job is to understand and influence each significant subsystem in order to maintain architectural integrity.

7. Get your hands dirty and code

Yes you should take parts of the code and implement them. Even the least glamorous parts. This will help you not getting stuck alone between management and the team. It will also help you gain respect in the team.

8. Act as a communication proxy for your team

In long complex projects with big teams communication is one of the most complicated aspects. The more people you have involved in solving a problem the bigger the communication matrix becomes. Since people need information to be able to make the right decisions this will lead to an exponential increase in the time consumed for communication. Agile methodologies alleviate this problem. But in the end it is up to you to propagate important information to the right people.

9. Make sure everybody understands the big picture: their work has implications

This will help you greatly because will allow team members to design and implement in a way that you don’t have to fight. It is also hard work from your part.

10. Fight for architecture and design consistency

Doing the right thing from the design and architecture point of view is not more costly. It is actually cheaper in every project longer than a couple of months. Every early investment in architecture pays for itself later during integration and maintenance. Even if you have to admit an occasional hack or prototype in the code base you should contain it in very specific modules.

11. Know the status of everybody’s work and detect slippage

This allows for corrective actions and for early communication with the management. You don’t want to be caught by surprise. Remember that during 90% of the allocated time for a task the code is 90% complete.

12. Record technical debt if you need shortcuts but try to maintain architectural integrity; report the debt

This one is very important for products that will have multiple releases. Technical debt should be analyzed at the beginning of each iteration.

13. Use the process that makes sense in your particular case

Tough one. Sometimes (most of the times?) the process is not up to you. In the enterprise usually the process is pre-decided. But always keep in mind that the process in itself means nothing. It is the people who give meaning to the process. Good people can make the worst process work while the wrong team cannot make any process work. Waterfall can be implemented in a very agile way and the agile methodologies can be applied with “rigor mortis” agility (see The Agile 800 Pounds Gorilla).

14. Avoid dogmas - question why everything is done the way is done; make sure everybody else knows the reasons

Sometimes I hear from programmers: we are agile and combine XP and Scrum and we also do TDD (Test Driven Development - I still hope for a TDD that means Thought Driven Development). The questions that pop up in my mind are: Do you need all those? Do you “really” do them by the book?
Anyway the point here is don’t do anything just because it is the way it has always been done. Understand why. Then explain the reasons to all team members. Rinse and repeat.

15. Avoid design by committee; listen to everybody but make your own decisions

No good design is born from referendum. There are lots of people making wild exotic suggestions when their a$$ is not on the line. There are also excessively prudent ideas born from fear. Even with good ideas you have to filter them and make them yours before you can include them in the design. A good architecture and a good design is usually born in one mind, an open mind that looks around. The obvious example is Linux.


Build your relationship with the team

16. Gain the team’s respect with the quality of your work and by doing what you are preaching17. Be fair
18. Admit your mistakes
19. Publicly recognize both team’s and individual members’ merits
20. Don’t blame anybody publicly for anything
21. Build morale and confidence by offering early victories to the team and to its individual members
22. Match people and tasks based on skills and their personal preference if possible; explain your decisions
23. Work the estimates with the team don’t come up with them
24. Mentor people
25. Listen to and learn from people
26. Explain your technical decisions

Build your relationship with the management and business people
27. Be sure you have authority along with responsibility
28. Be sure you get requirements and not architecture/design masked as requirements
29. Explain technical decisions in business terms
30. Try to be accurate in your estimates; avoid being too optimistic and don’t push it with hidden padding; explain the need for padding
31. Set reasonable expectations
32. Understand the relationships and dependencies with other teams or projects
33. Accurately report the status with alarms, explanations and solutions; report any technical debt
34. Resist pressure for change in requirements, and more important for shortcuts…
35. Be aware of politics
36. React to surprises with calm and with documented answers


]]>
Top 25 PHP template engines http://m.shnenglu.com/bigsml/archive/2008/10/29/65478.html娉℃場鐗?/dc:creator>娉℃場鐗?/author>Wed, 29 Oct 2008 13:28:00 GMThttp://m.shnenglu.com/bigsml/archive/2008/10/29/65478.htmlhttp://m.shnenglu.com/bigsml/comments/65478.htmlhttp://m.shnenglu.com/bigsml/archive/2008/10/29/65478.html#Feedback1http://m.shnenglu.com/bigsml/comments/commentRss/65478.htmlhttp://m.shnenglu.com/bigsml/services/trackbacks/65478.htmlhttp://www.whenpenguinsattack.com/2006/07/19/php-template-engine-roundup/ 


璇ユ枃鎬葷粨浜?php 鐨勪竴浜涙ā鏉? 鎴戜嬌鐢ㄨ繃鐨勬湁smarty, template lib, 榪樻湁鍚庢潵鐢ㄧ殑 Savant. 鎰熻smarty 澶鏉備簡, template lib 闇瑕佸涔犱竴浜涙爣絳? 騫朵笖涓嶆槸寰堝己澶? 緇煎悎鑰冭檻榪樻槸Savant 鏈濂? 鏃㈠彲浠ヤ嬌鐢ㄦā鏉挎満鍒? 鍙﹀欏甸潰妯℃澘鐩存帴浣跨敤php 鍑芥暟鏉ヨ緭鍑? 鍔熻兘涔熻繕鍙互.

Smarty
Smarty is a template engine that compiles the templates into PHP scripts, then executes those scripts. Very fast, very flexible.

Savant
A powerful but lightweight PEAR-compliant template system. It is non-compiling, and uses PHP itself as its template language.

Heyes Template Class

A very easy to use, yet powerful and quick template engine that enables you to separate your page layout and design from your code.

FastTemplate
A simple variable interpolation template class that parses your templates for variables and spits out HTML with their values

ShellPage
A simple and easy to use class that lets you make whole websites based on template files for layouts. Change the template and your whole site changes.

STP Simple Template Parser
A simple, light weight and easy to use template parser class. It can assemble a page from several templates, output result pages to the browser or write them to the filesystem.

OO Template Class
An object oriented template class you can use in your own programs.

SimpleTemplate
A template engine to create and structure websites and applications. It can translate and compile the templates.

bTemplate
A small and fast template class that allows you to separate your PHP logic from your HTML presentation code.

ETS - easy template system
A template system that allows you to reshuffle templates with exactly the same data.

EasyTemplatePHP
A simple, yet powerful templating system for your site.

vlibTemplate
A fast, full featured template system that includes a caching and debugging class.

AvanTemplate
A template engine that is multi-byte safe and consumes little computing resource. It supports variable replacement and content blocks that can be set to hidden or shown.

Grafx Software’s Fast Template
A modification of the popular Fast Template system, this includes a cache function, debug console, and silent removal of unassigned dynamic blocks.

TemplatePower
A fast, simple and powerful template class. Features nested dynamic block support, block/file include support and show/hide unassigned variables.

TagTemplate
This library function was designed for use with template files and allows you to retrieve info from HTML files.

htmltmpl: templating engine
A templating engine for Python and PHP. Targeted to web application developers, who want to separate program code and design of their projects.

PHP Class for Parsing Dreamweaver templates
A simple class to parse a Dreamweaver template for use in custom mods for a Gallery 2 and a WordPress blog.

MiniTemplator (Template Engine)
A compact template engine for HTML files. It features a simple syntax for template variables and blocks. Blocks can be nested.

Layout Solution
Simplifies website development and maintenance. It holds commonly used variables and page elements so you don’t need to duplicate common layouts over and over.

Cached Fast Template
This inclusion into FastTemplate allows for caching of the template files, and can even cache with different specifications on separate blocks of content.

TinyButStrong
A template engine that supports MySQL, Odbc, Sql-Server and ADODB. It includes seven methods and two properties.

Brian Lozier’s php based template engine
Only 2k in size, very fast and object-orientated.

WACT
a template engine that separates code from design.

PHPTAL
a XML/XHTML template library for PHP.

ref:
http://www.sitepoint.com/forums/showthread.php?t=123769 瀵瑰叾浠栫殑php 妯℃澘榪涜浜嗚璁?/p>

]]>
娣卞叆鐞嗚ВEffictive C++ "鏉℃38: 鍐充笉瑕侀噸鏂板畾涔夌戶鎵胯屾潵鐨勭己鐪佸弬鏁板? http://m.shnenglu.com/bigsml/archive/2008/10/06/63327.html娉℃場鐗?/dc:creator>娉℃場鐗?/author>Mon, 06 Oct 2008 09:19:00 GMThttp://m.shnenglu.com/bigsml/archive/2008/10/06/63327.htmlhttp://m.shnenglu.com/bigsml/comments/63327.htmlhttp://m.shnenglu.com/bigsml/archive/2008/10/06/63327.html#Feedback6http://m.shnenglu.com/bigsml/comments/commentRss/63327.htmlhttp://m.shnenglu.com/bigsml/services/trackbacks/63327.html鐪嬫潯嬈?8 鐨勬椂鍊欎笉鏄緢鐞嗚В, 浜庢槸鍐欎簡涓祴璇曚唬鐮?

#include<iostream> 
using namespace std; 

class A{
public:
    
virtual void show(int a=145)
    {
        cout
<<"A: a="<<a<<endl; 
    }   
}; 

class B: public A 

public
    
void show(int b)
    { 
        cout
<<"B: b="<<b<<endl; 
    } 
}; 
class C: public B 

public
    
void show(int c=999)
    { 
        cout
<<"C: c="<<c<<endl; 
    } 
};
class D: public C 

public
    
void show()
    { 
        cout
<<"D:\n"
    }
}; 

void main() 
{
    A 
*pp;
    A a; 
    B b; 
    C c; 
    D d;
    
    a.show();
    pp 
= &a;    pp->show();

    
// b.show();  // error C2660: 'B::show' : function does not take 0 arguments
    pp = &b;    pp->show();
    
    c.show();
    pp 
= &c;    pp->show();

    d.show();
    pp 
= &d;    pp->show();
    
    C 
*pc= &d;
    pc
->show();

    system(
"pause"); 
}   
杈撳嚭緇撴灉鏄?br>
A: a=145
A: a=145
B: b=145
C: c=999
C: c=145
D:
C: c=145
C: c=999

鍥為【鏉℃ 
铏氬嚱鏁版槸鍔ㄦ佺粦瀹氳岀己鐪佸弬鏁板兼槸闈欐佺粦瀹氱殑.  涓轟粈涔圕++鍧氭寔榪欑鏈夎繚甯歌鐨勫仛娉曞憿錛熺瓟妗堝拰榪愯鏁堢巼鏈夊叧銆傚鏋滅己鐪佸弬鏁板艱鍔ㄦ佺粦瀹氾紝緙栬瘧鍣ㄥ氨蹇呴』鎯沖姙娉曚負铏氬嚱鏁板湪榪愯鏃剁‘瀹氬悎閫傜殑緙虹渷鍊鹼紝榪欏皢姣旂幇鍦ㄩ噰鐢ㄧ殑鍦ㄧ紪璇戦樁孌電‘瀹氱己鐪佸肩殑鏈哄埗鏇存參鏇村鏉傘傚仛鍑鴻繖縐嶉夋嫨鏄兂姹傚緱閫熷害涓婄殑鎻愰珮鍜屽疄鐜頒笂鐨勭畝渚匡紝鎵浠ュぇ瀹剁幇鍦ㄦ墠鑳芥劅鍙楀緱鍒扮▼搴忚繍琛岀殑楂樻晥錛?

鎵浠?
a. 闈欐佺粦瀹?.vs. 鍔ㄦ佺粦瀹?
A *pp = new B;
榪欓噷 pp 闈欐佺粦瀹氭槸 A* , 鑰屽姩鎬佺粦瀹氬嵈鏄?B*
B *pb = new B;
榪欓噷 pb 闈欐佺粦瀹氬拰鍔ㄦ佺粦瀹氭槸涓鏍風殑閮芥槸 B*

b. 緙虹渷鍊兼槸闈欐佺粦瀹氱殑, 鑰岄潪鍔ㄦ佺粦瀹?
鎵浠?
d.show() 杈撳嚭 D:  鍥犱負show 琚?D override

pp = &d;    pp->show();  
pp 琚姩鎬佺粦瀹氬埌D *, 浣嗘槸show 鐨勭己鐪佸煎嵈鏄疉* 鐨?145, 鎵浠ヨ緭鍑虹殑鏄?C: c=145, 鑰屼笉鏄?99 ( 鍑芥暟 show 琚獵 緇檕verride 浜? 

鑰?nbsp;C *pc = &d; pc->show() , pc 闈欐佺粦瀹氫負C*, 鑰屽姩鎬佺粦瀹氫負 D* , 鎵浠ヨ緭鍑虹殑鏄?C: c=999 , 999 鏄?C* 闈欐佺粦瀹氱殑緙虹渷鍊?

c. 鎵浠ヨ皟鐢╞.show 鐨勬椂鍊欏嚭鐜頒簡濡備笅鐨勯敊璇?
    // b.show();  // error C2660: 'B::show' : function does not take 0 arguments
鍥犱負 B* 娌℃湁闈欐佺粦瀹氱殑鍑芥暟

緇撹灝辨槸 鍐充笉瑕侀噸鏂板畾涔夌戶鎵胯屾潵鐨勭己鐪佸弬鏁板?nbsp;

ref: 
浠庤繖閲屽浜嗕笉灝?) http://bbs.chinaunix.net/viewthread.php?tid=439188 


]]>
Python 鎿嶄綔榛戣帗(Blackberry)閫氫俊褰?/title><link>http://m.shnenglu.com/bigsml/archive/2008/10/03/63207.html</link><dc:creator>娉℃場鐗?/dc:creator><author>娉℃場鐗?/author><pubDate>Fri, 03 Oct 2008 14:18:00 GMT</pubDate><guid>http://m.shnenglu.com/bigsml/archive/2008/10/03/63207.html</guid><wfw:comment>http://m.shnenglu.com/bigsml/comments/63207.html</wfw:comment><comments>http://m.shnenglu.com/bigsml/archive/2008/10/03/63207.html#Feedback</comments><slash:comments>6</slash:comments><wfw:commentRss>http://m.shnenglu.com/bigsml/comments/commentRss/63207.html</wfw:commentRss><trackback:ping>http://m.shnenglu.com/bigsml/services/trackbacks/63207.html</trackback:ping><description><![CDATA[涓轟簡緇欓粦鑾撳鍏Phone 鐨勯氫俊褰?contacts) , 鍙兘鍒╃敤榛戣帗鐨勬闈㈢鐞嗗櫒, 閫氳繃ipd 鏉ョ淮鎶? <br>浣嗘槸鍙戠幇 ABC Amber BlackBerry Converter 鍙兘杞崲鑰屾棤娉曚慨鏀? IPDManager 鍙兘緇存姢閾冨0鍜岄煶涔愬暐鐨?(  鍙兘鑷繁鍐欎簡涓皬紼嬪簭 <br><br>ipd 鐨勬牸寮忓彲浠ュ湪 <a >http://na.blackberry.com/eng/developers/resources/journals/jan_2006/ipd_file_format.jsp</a> 榪欓噷鎵懼埌, 鍚庨潰鏄唬鐮? 鍙槸鐢熸垚datablock 鍒楄〃, 榪橀渶瑕侀澶栨嫹璐? 鎿嶄綔鏃舵渶濂藉彧鍚屾閫氫俊褰? <br><br>涓嬮潰鏄唬鐮?<br> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008000">#</span><span style="COLOR: #008000">!/usr/local/bin/python2.5 </span><span style="COLOR: #008000"><br>#</span><span style="COLOR: #008000">-*- coding: gbk -*-</span><span style="COLOR: #008000"><br></span><span style="COLOR: #0000ff">from</span><span style="COLOR: #000000"> struct </span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> <br><br></span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> BBFile:    <br>    </span><span style="COLOR: #0000ff">def</span><span style="COLOR: #000000"> </span><span style="COLOR: #800080">__init__</span><span style="COLOR: #000000">(self):<br>        </span><span style="COLOR: #0000ff">pass</span><span style="COLOR: #000000"><br>        <br>    </span><span style="COLOR: #0000ff">def</span><span style="COLOR: #000000"> _contactblock(self, name, phone, uid):<br>        s </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #800000">''</span><span style="COLOR: #000000"><br>        </span><span style="COLOR: #008000">#</span><span style="COLOR: #008000"> name </span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">        name </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> name.encode(</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">utf-16be</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">)<br>        s </span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000"> pack(</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000"><HB</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">, len(name)</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">0xa0</span><span style="COLOR: #000000">)<br>        s </span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000"> pack(</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000"><B</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">0x01</span><span style="COLOR: #000000">) </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> name<br>        </span><span style="COLOR: #008000">#</span><span style="COLOR: #008000"> ff * 8 </span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">        s </span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000"> pack(</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000"><HB</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">8</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">0x54</span><span style="COLOR: #000000">)<br>        s </span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000"> </span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">\xff</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">8</span><span style="COLOR: #000000"><br>        </span><span style="COLOR: #008000">#</span><span style="COLOR: #008000"> uid </span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">        s </span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000"> pack(</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000"><HBI</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">4</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">0x55</span><span style="COLOR: #000000">, uid)<br>        </span><span style="COLOR: #008000">#</span><span style="COLOR: #008000"> phone</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">        phone </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> phone.encode(</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">gbk</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">)<br>        s </span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000"> pack(</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000"><HB</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">, len(phone)</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">0x08</span><span style="COLOR: #000000">)<br>        s </span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000"> phone </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> </span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">\x00</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000"><br>        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> s <br>    <br>    </span><span style="COLOR: #0000ff">def</span><span style="COLOR: #000000"> save(self, filename, us, dbID</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0, dbVer</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0):<br>        hf </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> open(filename, </span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">w+b</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">)<br>        rs, uid </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">363797835</span><span style="COLOR: #000000"> </span><span style="COLOR: #008000">#</span><span style="COLOR: #008000"> 鍒濆鍊?/span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> u </span><span style="COLOR: #0000ff">in</span><span style="COLOR: #000000"> us:<br>            s </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> self._contactblock(u[0], u[</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">], uid)<br>            h </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> pack(</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000"><HIBHI</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">, dbID, len(s)</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">7</span><span style="COLOR: #000000">, dbVer, rs, uid)<br>            hf.write(h </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> s)<br>            uid </span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">8</span><span style="COLOR: #000000">    </span><span style="COLOR: #008000">#</span><span style="COLOR: #008000"> </span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">            rs  </span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">    </span><span style="COLOR: #008000">#</span><span style="COLOR: #008000"> </span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">        hf.close()<br>        <br></span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> </span><span style="COLOR: #800080">__name__</span><span style="COLOR: #000000">==</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">__main__</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">:<br>    bb </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> BBFile()<br>    us </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> [ (u</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">瀹濆疂1</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">, u</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">13888888888</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">),(u</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">瀹濆疂2</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">, u</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">13888888888</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">),(u</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">瀹濆疂3</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">, u</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">13888888888</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">),  ]    <br>    bb.save(</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">bb.ipd</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">, us, 0, 0)<br></span></div> 1. 淇濆瓨鎴愭枃浠跺氨鍙互鐩存帴榪愯浜?) <br>2. 濡傛灉瑕佺湡鐨勭敓鎴愬彲浠ュ鍏b 鐨勬枃浠剁殑璇? 瑕佷嬌鐢ㄩ珮綰?> 鍙悓姝ラ氳褰? 鐒跺悗灝嗚繖涓枃浠剁敓鎴愮殑鍐呭鏀懼湪瀵煎嚭鏂囦歡鐨勫ご鐨勫悗闈? 榪樻槸鏈夌偣楹葷儲.... 鏈夌┖鍋氫釜鍏ㄨ嚜鍔ㄧ殑 鍛靛懙   <br><br>鍥犱負鍙槸嫻嬭瘯, 鎵浠ュ緢澶氱‖緙栫爜浜?)    <br><br> <img src ="http://m.shnenglu.com/bigsml/aggbug/63207.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.shnenglu.com/bigsml/" target="_blank">娉℃場鐗?/a> 2008-10-03 22:18 <a href="http://m.shnenglu.com/bigsml/archive/2008/10/03/63207.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Http 鍩虹http://m.shnenglu.com/bigsml/archive/2008/09/25/62754.html娉℃場鐗?/dc:creator>娉℃場鐗?/author>Thu, 25 Sep 2008 06:05:00 GMThttp://m.shnenglu.com/bigsml/archive/2008/09/25/62754.htmlhttp://m.shnenglu.com/bigsml/comments/62754.htmlhttp://m.shnenglu.com/bigsml/archive/2008/09/25/62754.html#Feedback1http://m.shnenglu.com/bigsml/comments/commentRss/62754.htmlhttp://m.shnenglu.com/bigsml/services/trackbacks/62754.html= HTTP 鍩虹
涓涓畬鏁寸殑 HTTP 璇鋒眰鍙互鍒嗘垚4姝?
 1. 鍒涘緩TCP socket, 榪炴帴鍒癢eb 鏈嶅姟鍣?br> 2. 鍙戦丠ttp 璇鋒眰澶?br> 3. 鎺ュ彈Web 鍝嶅簲鏁版嵁
 4. 鍏抽棴socket 榪炴帴
鏁翠釜嫻佺▼鍙互閫氳繃telnet hostname 80 鏉ユā鎷?br>涓涓畬鏁寸殑璇鋒眰渚嬪瓙濡備笅
* About to connect() to www.baidu.com port 80 (#0)
*   Trying 202.108.22.5... connected
* Connected to www.baidu.com (202.108.22.5) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.16.4 (i586-pc-mingw32msvc) libcurl/7.16.4 OpenSSL/0.9.7e zlib/1.2.2
> Host: www.baidu.com
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Thu, 25 Sep 2008 05:14:30 GMT
< Server: BWS/1.0
< Content-Length: 3342
< Content-Type: text/html
< Cache-Control: private
< Expires: Thu, 25 Sep 2008 05:14:30 GMT
< Set-Cookie: BAIDUID=3A8165EF68FFEE5F605D33ADEF300BA1:FG=1; expires=Thu, 25-Sep-38 05:14:30 GMT; path=/; domain=.baidu.com
< P3P: CP=" OTI DSP COR IVA OUR IND COM "
<
<html><head><meta http-equiv=Content-Type content="text/html;charset=gb2312"><title>......

鍙﹀鍊煎緱璇存槑鐨勬槸, HTTP 璇鋒眰鏄棤鐘舵佺殑錛岃〃鏄庡湪澶勭悊涓涓姹傛椂錛學eb鏈嶅姟鍣ㄥ茍涓嶈浣忔潵鑷悓涓瀹㈡埛绔殑璇鋒眰銆?/p>

= Http 璇鋒眰澶?
鍖呭惈4涓儴鍒? 璇鋒眰琛屻佽姹傚ご銆佺┖琛屽拰璇鋒眰鏁版嵁

1. 璇鋒眰琛?br>鐢變笁涓爣璁扮粍鎴愶細璇鋒眰鏂規硶銆佽姹俇RI鍜孒TTP鐗堟湰錛屽畠浠敤絀烘牸鍒嗛殧, 濡傦細GET /index.html HTTP/1.1

HTTP 瑙勮寖瀹氫箟浜?縐嶈姹傛柟娉曪細
GET   媯绱RI涓爣璇嗚祫婧愮殑涓涓畝鍗曡姹?br>HEAD   涓嶨ET鏂規硶鐩稿悓錛屾湇鍔″櫒鍙繑鍥炵姸鎬佽鍜屽ご鏍囷紝騫朵笉榪斿洖璇鋒眰鏂囨。
POST   鏈嶅姟鍣ㄦ帴鍙楄鍐欏叆瀹㈡埛绔緭鍑烘祦涓殑鏁版嵁鐨勮姹?br>PUT   鏈嶅姟鍣ㄤ繚瀛樿姹傛暟鎹綔涓烘寚瀹歎RI鏂板唴瀹圭殑璇鋒眰
DELETE   鏈嶅姟鍣ㄥ垹闄RI涓懡鍚嶇殑璧勬簮鐨勮姹?br>OPTIONS  鍏充簬鏈嶅姟鍣ㄦ敮鎸佺殑璇鋒眰鏂規硶淇℃伅鐨勮姹?br>TRACE   Web鏈嶅姟鍣ㄥ弽棣圚ttp璇鋒眰鍜屽叾澶存爣鐨勮姹?br>CONNECT  宸叉枃妗e寲浣嗗綋鍓嶆湭瀹炵幇鐨勪竴涓柟娉曪紝棰勭暀鍋氶毀閬撳鐞?/p>

2. 璇鋒眰澶?[ 鍙棤 ]
鐢卞叧閿瓧鍙婂煎緇勬垚錛屾瘡琛屼竴瀵癸紝鍏抽敭瀛楀拰鍊肩敤鍐掑彿錛?錛夊垎闅斻傚
> User-Agent: curl/7.16.4 (i586-pc-mingw32msvc) libcurl/7.16.4 OpenSSL/0.9.7e zlib/1.2.2
> Host: www.baidu.com
> Accept: */*
鍏蜂綋璇鋒眰澶村鍚庢墍鍒?

3. 絀鴻
鏈鍚庝竴涓姹傚ご涔嬪悗鏄竴涓┖琛岋紝鍙戦佸洖杞︾鍜岄琛岋紝閫氱煡鏈嶅姟鍣ㄤ互涓嬩笉鍐嶆湁澶存爣銆?/p>

4. 璇鋒眰鏁版嵁 [ 鍙棤 ]
浣跨敤POST浼犻佹暟鎹紝鏈甯鎬嬌鐢ㄧ殑鏄疌ontent-Type鍜孋ontent-Length澶存爣


= Web 鍝嶅簲
鐢卞洓涓儴鍒嗙粍鎴? 鐘舵佽銆佸搷搴斿ご銆佺┖琛屻佸搷搴旀暟鎹? 濡?
< HTTP/1.1 200 OK
< Date: Thu, 25 Sep 2008 05:14:30 GMT
< Server: BWS/1.0
< Content-Length: 3342
< Content-Type: text/html
< Cache-Control: private
< Expires: Thu, 25 Sep 2008 05:14:30 GMT
< Set-Cookie: BAIDUID=3A8165EF68FFEE5F605D33ADEF300BA1:FG=1; expires=Thu, 25-Sep-38 05:14:30 GMT; path=/; domain=.baidu.com
< P3P: CP=" OTI DSP COR IVA OUR IND COM "
<
<html><head><meta http-equiv=Content-Type content="text/html;charset=gb2312"><title>......

1.鐘舵佽
鐢變笁涓爣璁扮粍鎴愶細HTTP鐗堟湰銆佸搷搴斾唬鐮佸拰鍝嶅簲鎻忚堪
HTTP鐗堟湰:: 鍚戝鎴風鎸囨槑鍏跺彲鐞嗚В鐨勬渶楂樼増鏈?br>鍝嶅簲浠g爜:: 3浣嶇殑鏁板瓧浠g爜錛屾寚鍑鴻姹傜殑鎴愬姛鎴栧け璐ワ紝濡傛灉澶辮觸鍒欐寚鍑哄師鍥犮?br>鍝嶅簲鎻忚堪:: 涓哄搷搴斾唬鐮佺殑鍙鎬цВ閲娿?br>濡?
< HTTP/1.1 200 OK

HTTP鍝嶅簲鐮佸垝鍒嗗涓?紲ヨ鍚?錛?br>1xx錛氫俊鎭紝璇鋒眰鏀跺埌錛岀戶緇鐞?br>2xx錛氭垚鍔燂紝琛屼負琚垚鍔熷湴鎺ュ彈銆佺悊瑙e拰閲囩撼
3xx錛氶噸瀹氬悜錛屼負浜嗗畬鎴愯姹傦紝蹇呴』榪涗竴姝ユ墽琛岀殑鍔ㄤ綔
4xx錛氬鎴風閿欒


2.鍝嶅簲澶?br>璺熻姹傚ご涓鏍鳳紝瀹冧滑鎸囧嚭鏈嶅姟鍣ㄧ殑鍔熻兘錛屾爣璇嗗嚭鍝嶅簲鏁版嵁鐨勭粏鑺傘?/p>

3.絀鴻
鏈鍚庝竴涓搷搴斿ご鏍囦箣鍚庢槸涓涓┖琛岋紝鍙戦佸洖杞︾鍜岄琛岋紝琛ㄦ槑鏈嶅姟鍣ㄤ互涓嬩笉鍐嶆湁澶存爣銆?/p>

4.鍝嶅簲鏁版嵁
HTML鏂囨。鍜屽浘鍍忕瓑錛屽氨鏄疕TML鏈韓銆?


= HTTP澶?br>鐢ㄤ互鎻忚堪瀹㈡埛绔垨鑰呮湇鍔″櫒鐨勫睘鎬с佽浼犺緭鐨勮祫婧愮瓑, 鍒嗕負
1.閫氱敤澶存爣錛氬嵆鍙敤浜庤姹傦紝涔熷彲鐢ㄤ簬鍝嶅簲錛屾槸浣滀負涓涓暣浣撹屼笉鏄壒瀹氳祫婧愪笌浜嬪姟鐩稿叧鑱斻?br>2.璇鋒眰澶存爣錛氬厑璁稿鎴風浼犻掑叧浜庤嚜韜殑淇℃伅鍜屽笇鏈涚殑鍝嶅簲褰㈠紡銆?br>3.鍝嶅簲澶存爣錛氭湇鍔″櫒鍜屼簬浼犻掕嚜韜俊鎭殑鍝嶅簲銆?br>4.瀹炰綋澶存爣錛氬畾涔夎浼犻佽祫婧愮殑淇℃伅銆傚嵆鍙敤浜庤姹傦紝涔熷彲鐢ㄤ簬鍝嶅簲銆?/p>

涓嬭〃鎻忚堪鍦℉TTP/1.1涓敤鍒扮殑澶存爣
Accept   瀹氫箟瀹㈡埛绔彲浠ュ鐞嗙殑濯掍綋綾誨瀷錛屾寜浼樺厛綰ф帓搴忥紱
  鍦ㄤ竴涓互閫楀彿涓哄垎闅旂殑鍒楄〃涓紝鍙互瀹氫箟澶氱綾誨瀷鍜屼嬌鐢ㄩ氶厤絎︺備緥濡傦細Accept: image/jpeg,image/png,*/*
Accept-Charset  瀹氫箟瀹㈡埛绔彲浠ュ鐞嗙殑瀛楃闆嗭紝鎸変紭鍏堢駭鎺掑簭錛?br>  鍦ㄤ竴涓互閫楀彿涓哄垎闅旂殑鍒楄〃涓紝鍙互瀹氫箟澶氱綾誨瀷鍜屼嬌鐢ㄩ氶厤絎︺備緥濡傦細Accept-Charset: iso-8859-1,*,utf-8
Accept-Encoding 瀹氫箟瀹㈡埛绔彲浠ョ悊瑙g殑緙栫爜鏈哄埗銆備緥濡傦細Accept-Encoding:gzip,compress
Accept-Language 瀹氫箟瀹㈡埛绔箰浜庢帴鍙楃殑鑷劧璇█鍒楄〃銆備緥濡傦細Accept-Language: en,de
Accept-Ranges  涓涓搷搴斿ご鏍囷紝瀹冨厑璁告湇鍔″櫒鎸囨槑錛氬皢鍦ㄧ粰瀹氱殑鍋忕Щ鍜岄暱搴﹀錛屼負璧勬簮緇勬垚閮ㄥ垎鐨勬帴鍙楄姹傘?br>  璇ュご鏍囩殑鍊艱鐞嗚В涓鴻姹傝寖鍥寸殑搴﹂噺鍗曚綅銆備緥濡侫ccept-Ranges: bytes鎴朅ccept-Ranges: none
Age   鍏佽鏈嶅姟鍣ㄨ瀹氳嚜鏈嶅姟鍣ㄧ敓鎴愯鍝嶅簲浠ユ潵鎵緇忚繃鐨勬椂闂撮暱搴︼紝浠ョ涓哄崟浣嶃?br>  璇ュご鏍囦富瑕佺敤浜庣紦瀛樺搷搴斻備緥濡傦細Age: 30
Allow   涓涓搷搴斿ご鏍囷紝瀹冨畾涔変竴涓敱浣嶄簬璇鋒眰URI涓殑嬈℃簮鎵鏀寔鐨凥TTP鏂規硶鍒楄〃銆備緥濡傦細Allow: GET,PUT
AUTHORIZATION  涓涓搷搴斿ご鏍囷紝鐢ㄤ簬瀹氫箟璁塊棶涓縐嶈祫婧愭墍蹇呴渶鐨勬巿鏉冿紙鍩熷拰琚紪鐮佺殑鐢ㄦ埛ID涓庡彛浠わ級銆?br>  渚嬪錛欰uthorization: Basic YXV0aG9yOnBoaWw=
Cache-Control  涓涓敤浜庡畾涔夌紦瀛樻寚浠ょ殑閫氱敤澶存爣銆備緥濡傦細Cache-Control: max-age=30
Connection  涓涓敤浜庤〃鏄庢槸鍚︿繚瀛榮ocket榪炴帴涓哄紑鏀劇殑閫氱敤澶存爣銆備緥濡傦細Connection: close鎴朇onnection: keep-alive
Content-Base  涓縐嶅畾涔夊熀鏈琔RI鐨勫疄浣撳ご鏍囷紝涓轟簡鍦ㄥ疄浣撹寖鍥村唴瑙f瀽鐩稿URLs銆?br>  濡傛灉娌℃湁瀹氫箟Content-Base澶存爣瑙f瀽鐩稿URLs錛屼嬌鐢–ontent-Location URI錛堝瓨鍦ㄤ笖緇濆錛夋垨浣跨敤URI璇鋒眰銆?br>  渚嬪錛欳ontent-Base: Http://www.myweb.com
Content-Encoding 涓縐嶄粙璐ㄧ被鍨嬩慨楗扮錛屾爣鏄庝竴涓疄浣撴槸濡備綍緙栫爜鐨勩備緥濡傦細Content-Encoding: zip
Content-Language 鐢ㄤ簬鎸囧畾鍦ㄨ緭鍏ユ祦涓暟鎹殑鑷劧璇█綾誨瀷銆備緥濡傦細Content-Language: en
Content-Length 鎸囧畾鍖呭惈浜庤姹傛垨鍝嶅簲涓暟鎹殑瀛楄妭闀垮害銆備緥濡傦細Content-Length:382
Content-Location 鎸囧畾鍖呭惈浜庤姹傛垨鍝嶅簲涓殑璧勬簮瀹氫綅錛圲RI錛夈?br>  濡傛灉鏄竴緇濄傚URL瀹冧篃浣滀負琚В鏋愬疄浣撶殑鐩稿URL鐨勫嚭鍙戠偣銆?br>  渚嬪錛欳ontent-Location: http://www.myweb.com/news
Content-MD5  瀹炰綋鐨勪竴縐峂D5鎽樿錛岀敤浣滄牎楠屽拰銆?br>  鍙戦佹柟鍜屾帴鍙楁柟閮借綆桵D5鎽樿錛屾帴鍙楁柟灝嗗叾璁$畻鐨勫間笌姝ゅご鏍囦腑浼犻掔殑鍊艱繘琛屾瘮杈冦?br>  渚嬪錛欳ontent-MD5: <base64 of 128 MD5 digest>
Content-Range  闅忛儴鍒嗗疄浣撲竴鍚屽彂閫侊紱鏍囨槑琚彃鍏ュ瓧鑺傜殑浣庝綅涓庨珮浣嶅瓧鑺傚亸縐伙紝涔熸爣鏄庢瀹炰綋鐨勬婚暱搴︺?br>  渚嬪錛欳ontent-Range: 1001-2000/5000
Contern-Type  鏍囨槑鍙戦佹垨鑰呮帴鏀剁殑瀹炰綋鐨凪IME綾誨瀷銆備緥濡傦細Content-Type: text/html
Date   鍙戦丠TTP娑堟伅鐨勬棩鏈熴備緥濡傦細Date: Mon,10PR 18:42:51 GMT
ETag   涓縐嶅疄浣撳ご鏍囷紝瀹冨悜琚彂閫佺殑璧勬簮鍒嗘淳涓涓敮涓鐨勬爣璇嗙銆?br>  瀵逛簬鍙互浣跨敤澶氱URL璇鋒眰鐨勮祫婧愶紝ETag鍙互鐢ㄤ簬紜畾瀹為檯琚彂閫佺殑璧勬簮鏄惁涓哄悓涓璧勬簮銆?br>  渚嬪錛欵Tag: "208f-419e-30f8dc99"
Expires  鎸囧畾瀹炰綋鐨勬湁鏁堟湡銆備緥濡傦細Expires: Mon,05 Dec 2008 12:00:00 GMT
Form   涓縐嶈姹傚ご鏍囷紝緇欏畾鎺у埗鐢ㄦ埛浠g悊鐨勪漢宸ョ敤鎴風殑鐢靛瓙閭歡鍦板潃銆備緥濡傦細From: webmaster@myweb.com
Host   琚姹傝祫婧愮殑涓繪満鍚嶃傚浜庝嬌鐢℉TTP/1.1鐨勮姹傝岃█錛屾鍩熸槸寮哄埗鎬х殑銆備緥濡傦細Host: www.myweb.com
If-Modified-Since 濡傛灉鍖呭惈浜咷ET璇鋒眰錛屽鑷磋璇鋒眰鏉′歡鎬у湴渚濊禆浜庤祫婧愪笂嬈′慨鏀規棩鏈熴?br>  濡傛灉鍑虹幇浜嗘澶存爣錛屽茍涓旇嚜鎸囧畾鏃ユ湡浠ユ潵錛屾璧勬簮宸茶淇敼錛屽簲璇ュ弽鍥炰竴涓?04鍝嶅簲浠g爜銆?br>  渚嬪錛欼f-Modified-Since: Mon,10PR 18:42:51 GMT
  If-Match 濡傛灉鍖呭惈浜庝竴涓姹傦紝鎸囧畾涓涓垨鑰呭涓疄浣撴爣璁般傚彧鍙戦佸叾ETag涓庡垪琛ㄤ腑鏍囪鍖洪厤鐨勮祫婧愩?br>  渚嬪錛欼f-Match: "208f-419e-308dc99"
  If-None-Match 濡傛灉鍖呭惈涓涓姹傦紝鎸囧畾涓涓垨鑰呭涓疄浣撴爣璁般傝祫婧愮殑ETag涓嶄笌鍒楄〃涓殑浠諱綍涓涓潯浠跺尮閰嶏紝鎿嶄綔鎵嶆墽琛屻?br>  渚嬪錛欼f-None-Match: "208f-419e-308dc99"
If-Range  鎸囧畾璧勬簮鐨勪竴涓疄浣撴爣璁幫紝瀹㈡埛绔凡緇忔嫢鏈夋璧勬簮鐨勪竴涓嫹璐濄傚繀欏諱笌Range澶存爣涓鍚屼嬌鐢ㄣ?br>  濡傛灉姝ゅ疄浣撹嚜涓婃琚鎴風媯绱互鏉ワ紝榪樹笉鏇句慨鏀硅繃錛岄偅涔堟湇鍔″櫒鍙彂閫佹寚瀹氱殑鑼冨洿錛屽惁鍒欏畠灝嗗彂閫佹暣涓祫婧愩?br>  渚嬪錛歊ange: byte=0-499<CRLF>If-Range:"208f-419e-30f8dc99"
If-Unmodified-Since 鍙湁鑷寚瀹氱殑鏃ユ湡浠ユ潵錛岃璇鋒眰鐨勫疄浣撹繕涓嶆浘琚慨鏀硅繃錛屾墠浼氳繑鍥炴瀹炰綋銆?br>  渚嬪錛欼f-Unmodified-Since:Mon,10PR 18:42:51 GMT
Last-Modified  鎸囧畾琚姹傝祫婧愪笂嬈¤淇敼鐨勬棩鏈熷拰鏃墮棿銆備緥濡傦細Last-Modified: Mon,10PR 18:42:51 GMT
Location  瀵逛簬涓涓凡緇忕Щ鍔ㄧ殑璧勬簮錛岀敤浜庨噸瀹氬悜璇鋒眰鑰呰嚦鍙︿竴涓綅緗?br>  涓庣姸鎬佺紪鐮?02錛堟殏鏃剁Щ鍔級鎴栬?01錛堟案涔呮хЩ鍔級閰嶅悎浣跨敤銆?br>  渚嬪錛歀ocation: http://www2.myweb.com/index.jsp
Max-Forwards  涓涓敤浜嶵RACE鏂規硶鐨勮姹傚ご鏍囷紝浠ユ寚瀹氫唬鐞嗘垨緗戝叧鐨勬渶澶ф暟鐩紝璇ヨ姹傞氳繃緗戝叧鎵嶅緱浠ヨ礬鐢便?br>  鍦ㄩ氳繃璇鋒眰浼犻掍箣鍓嶏紝浠g悊鎴栫綉鍏沖簲璇ュ噺灝戞鏁扮洰銆備緥濡傦細Max-Forwards: 3
Pragma   涓涓氱敤澶存爣錛屽畠鍙戦佸疄鐜扮浉鍏崇殑淇℃伅銆備緥濡傦細Pragma: no-cache
Proxy-Authenticate 綾諱技浜嶹WW-Authenticate錛屼究鏄湁鎰忚姹傚彧鏉ヨ嚜璇鋒眰閾撅紙浠g悊錛夌殑涓嬩竴涓湇鍔″櫒鐨勮璇併?br>  渚嬪錛歅roxy-Authenticate: Basic realm-admin
Proxy-Proxy-Authorization 綾諱技浜庢巿鏉冿紝浣嗗茍闈炴湁鎰忎紶閫掍換浣曟瘮鍦ㄥ嵆鏃舵湇鍔″櫒閾句腑鏇磋繘涓姝ョ殑鍐呭銆?br>  渚嬪錛歅roxy-Proxy-Authorization: Basic YXV0aG9yOnBoaWw=
Public   鍒楄〃鏄劇ず鏈嶅姟鍣ㄦ墍鏀寔鐨勬柟娉曢泦銆備緥濡傦細Public: OPTIONS,MGET,MHEAD,GET,HEAD
Range   鎸囧畾涓縐嶅害閲忓崟浣嶅拰涓涓儴鍒嗚璇鋒眰璧勬簮鐨勫亸縐昏寖鍥淬備緥濡傦細Range: bytes=206-5513
Refener  涓縐嶈姹傚ご鏍囧煙錛屾爣鏄庝駭鐢熻姹傜殑鍒濆璧勬簮銆傚浜嶩TML琛ㄥ崟錛屽畠鍖呭惈姝よ〃鍗曠殑Web欏甸潰鐨勫湴鍧銆?br>  渚嬪錛歊efener: http://www.myweb.com/news/search.html
Retry-After  涓縐嶅搷搴斿ご鏍囧煙錛岀敱鏈嶅姟鍣ㄤ笌鐘舵佺紪鐮?03錛堟棤娉曟彁渚涙湇鍔★級閰嶅悎鍙戦侊紝浠ユ爣鏄庡啀嬈¤姹備箣鍓嶅簲璇ョ瓑寰呭闀挎椂闂淬?br>  姝ゆ椂闂村嵆鍙互鏄竴縐嶆棩鏈燂紝涔熷彲浠ユ槸涓縐嶇鍗曚綅銆備緥濡傦細Retry-After: 18
Server   涓縐嶆爣鏄嶹eb鏈嶅姟鍣ㄨ蔣浠跺強鍏剁増鏈彿鐨勫ご鏍囥備緥濡傦細Server: Apache/2.0.46(Win32)
Transfer-Encoding 涓縐嶉氱敤澶存爣錛屾爣鏄庡搴旇鎺ュ彈鏂瑰弽鍚戠殑娑堟伅浣撳疄鏂藉彉鎹㈢殑綾誨瀷銆備緥濡傦細Transfer-Encoding: chunked
Upgrade  鍏佽鏈嶅姟鍣ㄦ寚瀹氫竴縐嶆柊鐨勫崗璁垨鑰呮柊鐨勫崗璁増鏈紝涓庡搷搴旂紪鐮?01錛堝垏鎹㈠崗璁級閰嶅悎浣跨敤銆?br>  渚嬪錛歎pgrade: HTTP/2.0
User-Agent  瀹氫箟鐢ㄤ簬浜х敓璇鋒眰鐨勮蔣浠剁被鍨嬶紙鍏稿瀷鐨勫Web嫻忚鍣級銆?br>  渚嬪錛歎ser-Agent: Mozilla/4.0(compatible; MSIE 5.5; Windows NT; DigExt)
Vary   涓涓搷搴斿ご鏍囷紝鐢ㄤ簬琛ㄧず浣跨敤鏈嶅姟鍣ㄩ┍鍔ㄧ殑鍗忓晢浠庡彲鐢ㄧ殑鍝嶅簲琛ㄧず涓夋嫨鍝嶅簲瀹炰綋銆備緥濡傦細Vary: *
Via   涓涓寘鍚墍鏈変腑闂翠富鏈哄拰鍗忚鐨勯氱敤澶存爣錛岀敤浜庢弧瓚寵姹傘備緥濡傦細Via: 1.0 fred.com, 1.1 wilma.com
Warning  鐢ㄤ簬鎻愪緵鍏充簬鍝嶅簲鐘舵佽ˉ鍏呬俊鎭殑鍝嶅簲澶存爣銆備緥濡傦細Warning: 99 www.myweb.com Piano needs tuning
www-Authenticate 涓涓彁紺虹敤鎴蜂唬鐞嗘彁渚涚敤鎴峰悕鍜屽彛浠ょ殑鍝嶅簲澶存爣錛屼笌鐘舵佺紪鐮?01錛堟湭鎺堟潈錛夐厤鍚堜嬌鐢ㄣ傚搷搴斾竴涓巿鏉冨ご鏍囥?br>  渚嬪錛歸ww-Authenticate: Basic realm=zxm.mgmt

= HTTP鐮佸簲鐮?br>鍝嶅簲鐮佺敱涓変綅鍗佽繘鍒舵暟瀛楃粍鎴愶紝瀹冧滑鍑虹幇鍦ㄧ敱HTTP鏈嶅姟鍣ㄥ彂閫佺殑鍝嶅簲鐨勭涓琛? 鍒嗕簲縐嶇被鍨嬶紝鐢卞畠浠殑絎竴浣嶆暟瀛楄〃紺猴細
- 1xx錛氫俊鎭紝璇鋒眰鏀跺埌錛岀戶緇鐞?br>- 2xx錛氭垚鍔燂紝琛屼負琚垚鍔熷湴鎺ュ彈銆佺悊瑙e拰閲囩撼
- 3xx錛氶噸瀹氬悜錛屼負浜嗗畬鎴愯姹傦紝蹇呴』榪涗竴姝ユ墽琛岀殑鍔ㄤ綔
- 4xx錛氬鎴風閿欒錛岃姹傚寘鍚娉曢敊璇垨鑰呰姹傛棤娉曞疄鐜?br>- 5xx錛氭湇鍔″櫒閿欒錛屾湇鍔″櫒涓嶈兘瀹炵幇涓縐嶆槑鏄炬棤鏁堢殑璇鋒眰

涓嬭〃鏄劇ず姣忎釜鍝嶅簲鐮佸強鍏跺惈涔夛細
100 緇х畫
101 鍒嗙粍浜ゆ崲鍗?br>200 OK
201 琚垱寤?br>202 琚噰綰?br>203 闈炴巿鏉冧俊鎭?br>204 鏃犲唴瀹?br>205 閲嶇疆鍐呭
206 閮ㄥ垎鍐呭
300 澶氶夐」
301 姘鎬箙鍦頒紶閫?br>302 鎵懼埌
303 鍙傝鍏朵粬
304 鏈敼鍔?br>305 浣跨敤浠g悊
307 鏆傛椂閲嶅畾鍚?br>400 閿欒璇鋒眰
401 鏈巿鏉?br>402 瑕佹眰浠樿垂
403 紱佹
404 鏈壘鍒?br>405 涓嶅厑璁哥殑鏂規硶
406 涓嶈閲囩撼
407 瑕佹眰浠g悊鎺堟潈
408 璇鋒眰瓚呮椂
409 鍐茬獊
410 榪囨湡鐨?br>411 瑕佹眰鐨勯暱搴?br>412 鍓嶆彁涓嶆垚绔?br>413 璇鋒眰瀹炰緥澶ぇ
414 璇鋒眰URI澶ぇ
415 涓嶆敮鎸佺殑濯掍綋綾誨瀷
416 鏃犳硶婊¤凍鐨勮姹傝寖鍥?br>417 澶辮觸鐨勯鏈?br>500 鍐呴儴鏈嶅姟鍣ㄩ敊璇?br>501 鏈浣跨敤
502 緗戝叧閿欒
503 涓嶅彲鐢ㄧ殑鏈嶅姟
504 緗戝叧瓚呮椂
505 HTTP鐗堟湰鏈鏀寔


= 瀹炰緥

== POST 鏁版嵁

== 涓婁紶涓涓枃浠?
鍋囪鎺ュ彈鏂囦歡鐨勭綉欏電▼搴忎綅浜?a
bb
ccc

瀹㈡埛绔摼鎺?192.168.29.65 鍚? 搴旇鍙戦佸涓媓ttp 璇鋒眰錛?br>POST /upload_file/UploadFile HTTP/1.1
Accept: text/plain, */*
Accept-Language: zh-cn
Host: 192.168.29.65
Content-Type:multipart/form-data;boundary=---------------------------7d33a816d302b6
User-Agent: Mozilla/4.0 (compatible; OpenOffice.org)
Content-Length: 333
Connection: Keep-Alive

-----------------------------7d33a816d302b6
Content-Disposition: form-data; name="userfile1"; filename="E:s"
Content-Type: application/octet-stream
a
bb
ccc
-----------------------------7d33a816d302b6
Content-Disposition: form-data; name="text1"
foo
-----------------------------7d33a816d302b6
Content-Disposition: form-data; name="password1"
bar
-----------------------------7d33a816d302b6--

(涓婇潰鏈変竴涓洖杞?

姝ゅ唴瀹瑰繀欏諱竴瀛椾笉宸紝鍖呮嫭鏈鍚庣殑鍥炶濺銆?
娉ㄦ剰錛欳ontent-Length: 333 榪欓噷鐨?33鏄孩鑹插唴瀹圭殑鎬婚暱搴︼紙鍖呮嫭鏈鍚庣殑鍥炶濺錛?
娉ㄦ剰榪欎竴琛岋細
Content-Type: multipart/form-data; boundary=---------------------------7d33a816d302b6
鏍規嵁 rfc1867, multipart/form-data鏄繀欏葷殑.
---------------------------7d33a816d302b6 鏄垎闅旂錛屽垎闅斿涓枃浠躲佽〃鍗曢」銆傚叾涓?3a816d302b6 鏄嵆鏃剁敓鎴愮殑涓涓暟瀛楋紝鐢ㄤ互紜繚鏁翠釜鍒嗛殧絎︿笉浼氬湪鏂囦歡鎴栬〃鍗曢」鐨勫唴瀹逛腑鍑虹幇銆?strong>Form姣忎釜閮ㄥ垎鐢ㄥ垎闅旂鍒嗗壊錛屽垎闅旂涔嬪墠蹇呴』鍔犱笂"--"鐫涓や釜瀛楃(鍗?-{boundary})鎵嶈兘琚玥ttp鍗忚璁や負鏄疐orm鐨勫垎闅旂錛岃〃紺虹粨鏉熺殑璇濈敤鍦ㄦ紜殑鍒嗛殧絎﹀悗闈㈡坊鍔?--"琛ㄧず緇撴潫銆?/strong>

鍓嶉潰鐨?---------------------------7d 鏄?IE 鐗規湁鐨勬爣蹇?Mozila 涓?--------------------------71.
姣忎釜鍒嗛殧鐨勬暟鎹殑閮藉彲浠ョ敤Content-Type鏉ヨ〃紺轟笅闈㈡暟鎹殑綾誨瀷錛屽彲浠ュ弬鑰價fc1341 (
http://www.ietf.org/rfc/rfc1341.txt) 渚嬪錛?
Contect-Type:application/octet-stream 琛ㄧず涓嬮潰鐨勬暟鎹槸浜岃繘鍒舵暟鎹?
Contect-Type:text/plain 琛ㄧず涓嬮潰鐨勬暟鎹槸ASSCII鐮佹暟鎹?
Contect-Type:text/richtext 琛ㄧず涓嬮潰鐨勬暟鎹槸RTF鏍煎紡



]]>
鍦?C++ 涓嬌鐢?Python script http://m.shnenglu.com/bigsml/archive/2008/08/14/58859.html娉℃場鐗?/dc:creator>娉℃場鐗?/author>Thu, 14 Aug 2008 09:55:00 GMThttp://m.shnenglu.com/bigsml/archive/2008/08/14/58859.htmlhttp://m.shnenglu.com/bigsml/comments/58859.htmlhttp://m.shnenglu.com/bigsml/archive/2008/08/14/58859.html#Feedback4http://m.shnenglu.com/bigsml/comments/commentRss/58859.htmlhttp://m.shnenglu.com/bigsml/services/trackbacks/58859.html鎯寵鍦╟++ 涓祵鍏cript 浠g爜, 闄や簡鑷繁鍐欒剼鏈紩鎿庡, lua, python 閮藉彲浠ュ湪c++ 涓嬌鐢? 鍙﹀ MonoBind, AngelScript library 閮芥槸涓浜沜++ script library, 鍙互宓屽叆鍒癱++ 涓嬌鐢?.
浠婂ぉ鍦╟++ 涓瘯鐫宓屽叆 python 浠g爜 (紺轟緥浠g爜鍦?Python-2.5.2\Demo\embed\ 涓?

#include <Python.h>
int main(int argc, char *argv[])
{
  
// Py_NoSiteFlag = 1;
  
// Py_SetPythonHome("D:\\usr\\Python"); // PYTHONHOME

  Py_Initialize();
  PyRun_SimpleString(
"from time import time,ctime\n"
                     
"print 'Today is',ctime(time())\n");
  Py_Finalize();
  
return 0;
}

鍦ㄨ繍琛屾椂鍙兘浼氫駭鐢熺被浼?'import site' failed; use -v for traceback 鐨勯敊璇? 鍘熷洜鏄痯ython 鍦╥mport module 鐨勬椂鍊欑殑璺緞闂. 鏈?縐嶆柟娉曞彲浠ヨВ鍐?浠ュ墠閫氳繃璁劇疆鐜鍙橀噺 PYTHONPATH 濂藉儚鍦?.5 宸茬粡鏃犳晥浜?.
0. 鍙栨秷娉ㄩ噴 Py_NoSiteFlag = 1;
榪欎釜鍙槸鍙栨秷import site , 褰撶劧濡傛灉鍦ㄤ唬鐮佷腑瑕乮mport 鍟ョ殑璇? 榪樻槸浼氬嚭鐜伴敊璇殑.
a. 璁劇疆鐜鍙橀噺 PYTHONHOME = D:\usr\Python 
b. 鍦ㄨ皟鐢?Py_Initialize 涔嬪墠璋冪敤鍑芥暟
Py_SetPythonHome("D:\\usr\\Python");  // 鍙傛暟鏄痯ython 鐨勫畨瑁呯洰褰?

2. 鍏朵粬涓浜涙湁鐢ㄧ殑璧勬簮
Python/C API Reference Manual (API 鍙傝? ,  Extending and Embedding the Python Interpreter (鎵╁睍鍙婂祵鍏ython瑙i噴鍣? 涓昏璇存槑浜嗗浣曟墿灞昉ython, 緇橮ython 鍐欐墿灞? 鍏朵腑 5. Embedding Python in Another Application  涓绔犺榪頒簡鍦–++涓祵鍏?璋冪敤Python 浠g爜 )

浣跨敤C/C++鎵╁睍Python  瀵規枃 Extending and Embedding the Python Interpreter 浣滀簡綺劇畝, 寰堜笉閿欑殑涓綃囨枃绔? 浣嗘槸璺寵繃浜嗕竴浜涘熀紜 .

Building Hybrid Systems with Boost.Python 浠嬬粛浜嗕嬌鐢╞oost.python 鏂逛究python 鎻掍歡寮鍙? python緇戝畾c++紼嬪簭 鏄叾涓枃鐗堟湰.

Embedding Python in Multi-Threaded C/C++ Applications 璁蹭簡c++鍦ㄥ綰跨▼鐜濡備綍浣跨敤Python , 鏂?nbsp;C++澶氱嚎紼嬩腑璋冪敤python api鍑芥暟 鎻愪緵浜嗕竴涓綰跨▼鐨勫皝瑁?

SCXX - A Simple Python/C++ API
http://davidf.sjsoft.com/mirrors/mcmillan-inc/scxx.html

C++鎵╁睍鍜屽祵鍏ython搴旂敤 (浠嬬粛浜嗕竴浜汸ython/C API 鍑芥暟, 浠ュ強ext 渚嬪瓙, 涓鑸埇)
http://hi.baidu.com/yunsweet/blog/item/20b08aeebaa2b1282cf534c7.html


3. Python 澶氱嚎紼嬬殑浣跨敤

zz http://blog.csdn.net/liguangyi/archive/2007/06/20/1659697.aspx 
浠婂ぉ鐪嬩簡榪戜竴澶╁叧浜庡綰跨▼鐨勫簲鐢ㄤ腑錛屽浣曞畨鍏ㄨ皟鐢╬ython鏂歸潰鐨勮祫鏂欙紝寮濮嬬殑鏃跺欑湅鐨勭畝鐩村ご澶у鏂楋紝琚玴ython璇█鐨勫叏灞閿?Global Interpreter Lock)銆佺嚎紼嬬姸鎬?Thread State )絳夐兘鏈夌偣緇曟檿浜嗭紝鍚庢潵緇忚繃鍚勬柟闈㈡枃绔犲拰甯姪鏂囨。鐨勭浉浜掑弬鑰冿紝鍙戠幇瀵逛簬2.4/2.5鐗堟湰錛屾彁渚涗簡PyGILState_Ensure, PyGILState_Release錛屽搸錛岃繖涓嬪彲鏂逛究澶у彂浜嗐?/p>

涓銆侀鍏堝畾涔変竴涓皝瑁呯被錛屼富瑕佹槸淇濊瘉PyGILState_Ensure, PyGILState_Release閰嶅浣跨敤錛岃屼笖榪欎釜綾繪槸鍙互宓屽浣跨敤鐨勩?/p>

#include <python.h>

class PyThreadStateLock
{
public:
    PyThreadStateLock(void)
    {
        state = PyGILState_Ensure( );
    }

    ~PyThreadStateLock(void)
    {
         PyGILState_Release( state );
    }
private:
    PyGILState_STATE state;
};


浜屻佸湪涓葷嚎紼嬩腑錛岃繖鏍峰鐞?/p>

    // 鍒濆鍖?br>    Py_Initialize();
    // 鍒濆鍖栫嚎紼嬫敮鎸?br>    PyEval_InitThreads();
    // 鍚姩瀛愮嚎紼嬪墠鎵ц錛屼負浜嗛噴鏀綪yEval_InitThreads鑾峰緱鐨勫叏灞閿侊紝鍚﹀垯瀛愮嚎紼嬪彲鑳芥棤娉曡幏鍙栧埌鍏ㄥ眬閿併?br>    PyEval_ReleaseThread(PyThreadState_Get());
  
    // 鍏朵粬鐨勫鐞嗭紝濡傚惎鍔ㄥ瓙綰跨▼絳?br>    ......
      
    // 淇濊瘉瀛愮嚎紼嬭皟鐢ㄩ兘緇撴潫鍚?br>    PyGILState_Ensure();
    Py_Finalize();
    // 涔嬪悗涓嶈兘鍐嶈皟鐢ㄤ換浣昿ython鐨凙PI

涓夈佸湪涓葷嚎紼嬶紝鎴栬呭瓙綰跨▼涓紝璋冪敤python鏈韓鍑芥暟鐨勯兘閲囩敤濡備笅澶勭悊

    {
        class PyThreadStateLock PyThreadLock;
        // 璋冪敤python鐨凙PI鍑芥暟澶勭悊
        ......
    }

鍛靛懙錛岀湅榪欐牱鏄惁闈炲父綆鍗曚簡銆?/p>


鍙﹀榪樻湁涓や釜鍜屽叏灞閿佹湁鍏崇殑瀹忥紝Py_BEGIN_ALLOW_THREADS 鍜?Py_END_ALLOW_THREADS銆傝繖涓や釜瀹忔槸涓轟簡鍦ㄨ緝闀挎椂闂寸殑C鍑芥暟璋冪敤鍓嶏紝涓存椂閲婃斁鍏ㄥ眬閿侊紝瀹屾垚鍚庨噸鏂拌幏鍙栧叏灞閿侊紝浠ラ伩鍏嶉樆濉炲叾浠杙ython鐨勭嚎紼嬬戶緇繍琛屻傝繖涓や釜瀹忓彲浠ヨ繖鏍瘋皟鐢?/p>

    {
        class PyThreadStateLock PyThreadLock;
        // 璋冪敤python鐨凙PI鍑芥暟澶勭悊
        ......

        Py_BEGIN_ALLOW_THREADS
        // 璋冪敤闇瑕侀暱鏃墮棿鐨凜鍑芥暟
        ......
        Py_END_ALLOW_THREADS

        // 璋冪敤python鐨凙PI鍑芥暟澶勭悊
        ......
    }

4. 鍙兘鐨勯敊璇強瑙e喅
a. 鍦╲s 200x 涓?debug 妯″紡鍑虹幇閾炬帴闂
extmodule.obj : error LNK2019: unresolved external symbol __imp___Py_Dealloc referenced in function _PySwigObject_format
extmodule.obj : error LNK2019: unresolved external symbol __imp___Py_NegativeRefcount referenced in function _PySwigObject_format
extmodule.obj : error LNK2001: unresolved external symbol __imp___Py_RefTotal
extmodule.obj : error LNK2019: unresolved external symbol __imp___PyObject_DebugFree referenced in function _PySwigObject_dealloc
extmodule.obj : error LNK2019: unresolved external symbol __imp___PyObject_DebugMalloc referenced in function _PySwigObject_New
extmodule.obj : error LNK2019: unresolved external symbol __imp__Py_InitModule4TraceRefs referenced in function _init_extmodule

涓昏鏄洜涓?Py_DEBUG/Py_TRACE_REFS 寮曡搗, 淇敼 Python\include 涓嬬殑 pyconfig.h, object.h 涓や釜鏂囦歡灝辮浜?... 璇﹁ http://www.nabble.com/link-error-in-debug-mode-td3126668.html 



]]>
浣跨敤 python 鍐?COM http://m.shnenglu.com/bigsml/archive/2008/08/14/58851.html娉℃場鐗?/dc:creator>娉℃場鐗?/author>Thu, 14 Aug 2008 09:02:00 GMThttp://m.shnenglu.com/bigsml/archive/2008/08/14/58851.htmlhttp://m.shnenglu.com/bigsml/comments/58851.htmlhttp://m.shnenglu.com/bigsml/archive/2008/08/14/58851.html#Feedback0http://m.shnenglu.com/bigsml/comments/commentRss/58851.htmlhttp://m.shnenglu.com/bigsml/services/trackbacks/58851.html1. com 璋冪敤紺轟緥(浣跨敤Windows Media Player 鎾斁闊充箰)
from win32com.client import Dispatch
mp 
= Dispatch("WMPlayer.OCX")
tune 
= mp.newMedia("C:/WINDOWS/system32/oobe/images/title.wma")
mp.currentPlaylist.appendItem(tune)
mp.controls.play()

2. com server 鐨勭紪鍐?br>涓昏鍙互鍙傝?<<Python Programming on Win32 涔?Chapter 12 Advanced Python and COM http://oreilly.com/catalog/pythonwin32/chapter/ch12.html >>
紺轟緥(鍒嗗壊瀛楃涓?
- 浠g爜
class PythonUtilities:
    _public_methods_ 
= [ 'SplitString' ]
    _reg_progid_ 
= "PythonDemos.Utilities"
    
# NEVER copy the following ID 
    # Use "print pythoncom.CreateGuid()" to make a new one.
    _reg_clsid_ = "{41E24E95-D45A-11D2-852C-204C4F4F5020}"
    
    
def SplitString(self, val, item=None):
        
import string
        
if item != None: item = str(item)
        
return string.split(str(val), item)
 
# Add code so that when this script is run by
#
 Python.exe, it self-registers.
if __name__=='__main__':
    
print "Registering COM server"
    
import win32com.server.register
    win32com.server.register.UseCommandLine(PythonUtilities)

- 娉ㄥ唽/娉ㄩ攢Com

Command-Line Option

Description

 

The default is to register the COM objects.

--unregister

Unregisters the objects. This removes all references to the objects from the Windows registry.

--debug

Registers the COM servers in debug mode. We discuss debugging COM servers later in this chapter.

--quiet

Register (or unregister) the object quietly (i.e., don't report success).


- 浣跨敤COM
鍙互鍦╬ython 鍛戒護琛屼笅榪愯
>>> import win32com.client
>>> s = win32com.client.Dispatch("PythonDemos.Utilities")
>>> s.SplitString("a,b,c"",")
((u
'a', u'a,b,c'),)
>>>

3. python server com 鍘熺悊
鍏跺疄鍦ㄦ敞鍐岃〃涓煡鎵懼埌python com 鐨勫疄鐜板唴騫?
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\CLSID\{41E24E95-D45A-11D2-852C-204C4F4F5020}]
@
="PythonDemos.Utilities"

[HKEY_CLASSES_ROOT\CLSID\{41E24E95-D45A-11D2-852C-204C4F4F5020}\Debugging]
@
="0"

[HKEY_CLASSES_ROOT\CLSID\{41E24E95-D45A-11D2-852C-204C4F4F5020}\Implemented Categories]

[HKEY_CLASSES_ROOT\CLSID\{41E24E95-D45A-11D2-852C-204C4F4F5020}\Implemented Categories\{B3EF80D0-68E2-11D0-A689-00C04FD658FF}]

[HKEY_CLASSES_ROOT\CLSID\{41E24E95-D45A-11D2-852C-204C4F4F5020}\InprocServer32]
@
="pythoncom25.dll"
"ThreadingModel"="both"

[HKEY_CLASSES_ROOT\CLSID\{41E24E95-D45A-11D2-852C-204C4F4F5020}\LocalServer32]
@
="D:\\usr\\Python\\pythonw.exe \"D:\\usr\\Python\\lib\\site-packages\\win32com\\server\\localserver.py\" {41E24E95-D45A-11D2-852C-204C4F4F5020}"

[HKEY_CLASSES_ROOT\CLSID\{41E24E95-D45A-11D2-852C-204C4F4F5020}\ProgID]
@
="PythonDemos.Utilities"

[HKEY_CLASSES_ROOT\CLSID\{41E24E95-D45A-11D2-852C-204C4F4F5020}\PythonCOM]
@
="PythonDemos.PythonUtilities"

[HKEY_CLASSES_ROOT\CLSID\{41E24E95-D45A-11D2-852C-204C4F4F5020}\PythonCOMPath]
@
="D:\\"

inproc server 鏄氳繃pythoncom25.dll 瀹炵幇
local server 閫氳繃localserver.py 瀹炵幇
com 瀵瑰簲鐨刾ython 婧愭枃浠朵俊鎭湪 PythonCOMPath & PythonCOM

4. 浣跨敤闂
鐢≒HP 鎴栬?c 璋冪敤com 鐨勬椂鍊?br>
<?php
$com = new COM("PythonDemos.Utilities");
$rs = $com->SplitString("a b c");
foreach($rs as $r)
    
echo $r."\n";
?>
浼氱鍒頒笅闈㈢殑涓浜涢敊璇?
pythoncom error: PythonCOM Server - The 'win32com.server.policy' module could not be loaded.
<type 'exceptions.ImportError'>: No module named server.policy pythoncom error: CPyFactory::CreateInstance failed to create instance. (80004005)


鍙互閫氳繃2縐嶆柟寮忚В鍐?
a. 璁劇疆鐜 PYTHONHOME = D:\usr\Python
鍙﹀鍦╟ ++ 浣跨敤python 鐨勬椂鍊? 濡傛灉import module 鍑虹幇閿欒 'import site' failed; use -v for traceback 鐨勮瘽, 涔熷彲浠ラ氳繃璁劇疆榪欎釜鍙橀噺瑙e喅.

b. 涓篶om 鐢熶駭exe, dll 鍙墽琛屾枃浠? setup.py 浠g爜濡備笅 :
from distutils.core import setup 
import py2exe 

import sys 
import shutil 

# Remove the build tree ALWAYS do that! 
shutil.rmtree("build", ignore_errors=True) 

# List of modules to exclude from the executable 
excludes = ["pywin""pywin.debugger""pywin.debugger.dbgcon""pywin.dialogs""pywin.dialogs.list"

# List of modules to include in the executable 
includes = ["win32com.server"

# ModuleFinder can't handle runtime changes to __path__, but win32com uses them 
try
    
# if this doesn't work, try import modulefinder 
    import py2exe.mf as modulefinder 
    
import win32com 
    
    
for p in win32com.__path__[1:]: 
        modulefinder.AddPackagePath(
"win32com", p) 
    
    
for extra in ["win32com.shell""win32com.server"]: #,"win32com.mapi" 
        __import__(extra) 
        m 
= sys.modules[extra] 
        
for p in m.__path__[1:]: 
            modulefinder.AddPackagePath(extra, p) 

except ImportError: 
    
# no build path setup, no worries. 
    pass 

# Set up py2exe with all the options 
setup( 
    options 
= {"py2exe": {"compressed"2
                          
"optimize"2
                          
#"bundle_files": 1, 
                          "dist_dir""COMDist"
                          
"excludes": excludes, 
                          
"includes": includes}}, 
    
# The lib directory contains everything except the executables and the python dll. 
    # Can include a subdirectory name. 
    zipfile = None, 
    com_server 
= ['PythonDemos'], # 鏂囦歡鍚?!
    ) 


ref:
http://oreilly.com/catalog/pythonwin32/chapter/ch12.html 
http://blog.donews.com/limodou/archive/2005/09/02/537571.aspx 


]]>
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲欧美国产视频| 国产精品草莓在线免费观看| 亚洲精品日韩在线观看| 免费不卡在线观看av| 久久久久久电影| 美女成人午夜| 亚洲茄子视频| 亚洲人成网在线播放| 99re6热只有精品免费观看| 一区二区三区|亚洲午夜| 午夜精品久久久| 久久久亚洲一区| 欧美裸体一区二区三区| 国产精品久久久久天堂| 国内精品久久久久伊人av| 亚洲国产精品成人精品| 在线一区二区三区做爰视频网站 | 亚洲日本中文字幕| 亚洲毛片在线免费观看| 亚洲一区影院| 欧美 日韩 国产 一区| 亚洲伦理在线观看| 久久精品女人天堂| 欧美系列电影免费观看| 伊人成人在线| 亚洲天堂免费观看| 久久一区二区三区国产精品| 亚洲国产婷婷| 久久不见久久见免费视频1| 欧美国产视频在线观看| 国产欧美三级| 一区二区三欧美| 久久人人爽国产| 在线一区亚洲| 欧美 日韩 国产 一区| 国产精品视频xxxx| 亚洲欧洲精品一区| 久久免费国产| 亚洲综合成人在线| 欧美日韩国产精品成人| 亚洲电影毛片| 久久久欧美一区二区| 亚洲系列中文字幕| 欧美日韩国产综合网| 亚洲在线观看免费| 欧美激情久久久久| 国产精品综合| 亚洲制服av| 欧美国产日韩精品免费观看| 午夜视频一区二区| 国产精品欧美经典| 亚洲一区在线观看视频 | 裸体一区二区三区| 国产伊人精品| 久久国内精品自在自线400部| 亚洲美女av黄| 欧美日韩国产美女| 一本久道久久综合狠狠爱| 欧美大片va欧美在线播放| 久久精品电影| 在线播放不卡| 欧美黄在线观看| 老司机亚洲精品| 亚洲欧洲日本在线| 亚洲激情偷拍| 欧美日韩久久| 亚洲一区二区三区乱码aⅴ蜜桃女| 亚洲黑丝在线| 欧美日韩免费一区二区三区| 99国产精品视频免费观看| 亚洲国产精品999| 欧美激情亚洲激情| 亚洲无限av看| 亚洲一区二区三区免费观看 | 久久天天躁夜夜躁狠狠躁2022| 亚洲一区二区在线播放| 国产欧美亚洲视频| 免费亚洲一区| 欧美区二区三区| 亚洲视频一区| 欧美一区二区成人6969| 在线成人激情| 亚洲免费高清| 国产日韩欧美麻豆| 欧美第一黄色网| 欧美日韩免费在线观看| 欧美一区二区三区视频在线观看| 欧美在线视频一区二区三区| 亚洲国产99| 在线一区视频| 亚洲国产精品成人综合色在线婷婷| 亚洲国产精品第一区二区| 欧美三级在线视频| 久久在线免费视频| 欧美日韩一区二区国产| 久久精品理论片| 欧美激情第3页| 久久成人综合视频| 欧美超级免费视 在线| 亚洲欧美综合国产精品一区| 久久久久综合网| 欧美日韩一区精品| 久久亚洲一区二区三区四区| 欧美屁股在线| 蜜臀av性久久久久蜜臀aⅴ| 欧美日韩大片一区二区三区| 欧美在线3区| 欧美日韩国产电影| 麻豆成人小视频| 国产精品白丝av嫩草影院| 欧美 日韩 国产在线| 国产精品一级| 日韩一级大片在线| 最新日韩av| 久久久久久网| 久久成人免费日本黄色| 欧美深夜福利| 亚洲国产天堂久久综合网| 激情小说另类小说亚洲欧美| 亚洲精品小视频| 亚洲精品欧美日韩| 麻豆91精品91久久久的内涵| 欧美中在线观看| 国产精品久久久久久久久借妻 | 欧美三级视频在线观看| 欧美凹凸一区二区三区视频| 国产精品亚发布| 亚洲午夜小视频| 亚洲综合色在线| 国产精品久久久久毛片大屁完整版 | 欧美日韩国产影院| 亚洲第一精品夜夜躁人人爽| 在线播放不卡| 久久中文精品| 欧美国产日本在线| 亚洲日本aⅴ片在线观看香蕉| 久久久综合视频| 美女视频黄免费的久久| 亚洲第一区中文99精品| 久久午夜色播影院免费高清| 蜜桃av噜噜一区二区三区| 怡红院av一区二区三区| 久久久人成影片一区二区三区| 老司机一区二区三区| 一区在线影院| 美女主播视频一区| 亚洲经典一区| 亚洲一区三区视频在线观看 | 国产精品日本精品| 亚洲欧美国产制服动漫| 欧美一区二区三区成人| 国产香蕉久久精品综合网| 欧美在线不卡| 欧美激情亚洲国产| 一区二区激情小说| 国产精品美女诱惑| 欧美在线日韩精品| 欧美成熟视频| 亚洲一区二区三区高清| 国产视频久久| 亚洲伦理久久| 亚洲欧美在线磁力| 国产综合视频在线观看| 美女久久一区| 99国产精品99久久久久久粉嫩| 午夜电影亚洲| 亚洲国产精品va在看黑人| 欧美啪啪成人vr| 欧美专区日韩视频| 亚洲黄一区二区| 久久精品99久久香蕉国产色戒| 最新热久久免费视频| 国产精品婷婷午夜在线观看| 久久综合久久88| 亚洲一区欧美激情| 欧美激情第六页| 香蕉av福利精品导航| 亚洲国产精品精华液2区45| 国产精品国产馆在线真实露脸| 久久国产婷婷国产香蕉| 日韩一区二区精品| 欧美成人免费全部| 久久精品国亚洲| 亚洲欧美精品中文字幕在线| 亚洲国产另类久久精品| 国产欧美一区二区精品性| 欧美精品v日韩精品v韩国精品v | 91久久久久久国产精品| 国产精品久久久久999| 欧美大片免费| 久久久精品五月天| 亚洲在线1234| 夜夜嗨av一区二区三区网站四季av| 噜噜噜在线观看免费视频日韩| 亚洲午夜视频在线观看| 亚洲国产视频一区| 黄色av日韩| 国产欧美丝祙| 国产精品一区二区在线观看网站| 欧美日韩免费精品|