Python ´®¿ÚÉ豸ӦÓÃ
1. Python ´®¿ÚÉ豸ӦÓÃ
¼òÊö
1.1. Ïß³ÌÂÖÑ°
·ç³¾ÎÞÏÞ <tianyu263@163.com>
-- ·ÖÏí
¾ÍÊÇ´ò¿ª´®¿Úºó£¬Æô¶¯Ò»¸öÏß³ÌÀ´¼àÌý´®¿ÚÊý¾ÝµÄ½øÈ룬ÓÐÊý¾Ýʱ£¬¾Í×öÊý¾ÝµÄ´¦Àí£¨Ò²¿ÉÒÔ·¢ËÍÒ»¸öʼþ£¬²¢Ð¯´ø½ÓÊÕµ½µÄÊý¾Ý£©¡£
Toggle line numbers
1
2 #coding=gb18030
3
4 import sys,threading,time;
5 import serial;
6 import binascii,encodings;
7 import re;
8 import socket;
9
10 class ReadThread:
11 def __init__(self, Output=None, Port=0, Log=None, i_FirstMethod=True):
12 self.l_serial = None;
13 self.alive = False;
14 self.waitEnd = None;
15 self.bFirstMethod = i_FirstMethod;
16 self.sendport = '';
17 self.log = Log;
18 self.output = Output;
19 self.port = Port;
20 self.re_num = None;
21
22 def waiting(self):
23 if not self.waitEnd is None:
24 self.waitEnd.wait();
25
26 def SetStopEvent(self):
27 if not self.waitEnd is None:
28 self.waitEnd.set();
29 self.alive = False;
30 self.stop();
31
32 def start(self):
33 self.l_serial = serial.Serial();
34 self.l_serial.port = self.port;
35 self.l_serial.baudrate = 9600;
36 self.l_serial.timeout = 2;
37
38 self.re_num = re.compile('\d');
39
40 try:
41 if not self.output is None:
42 self.output.WriteText(u'´ò¿ªÍ¨Ñ¶¶Ë¿Ú\r\n');
43 if not self.log is None:
44 self.log.info(u'´ò¿ªÍ¨Ñ¶¶Ë¿Ú');
45 self.l_serial.open();
46 except Exception, ex:
47 if self.l_serial.isOpen():
48 self.l_serial.close();
49
50 self.l_serial = None;
51
52 if not self.output is None:
53 self.output.WriteText(u'³ö´í£º\r\n %s\r\n' % ex);
54 if not self.log is None:
Ïà¹ØÎĵµ£º
×÷Ϊһ¸ö³õѧshellµÄ³ÌÐòÔ±À´Ëµ£¬Ê¹ÓÃshellµÄһЩÃüÁîµ÷Ó㬱ÈÈç¾Íд¼¸ÐУ¬×öһЩ×Ô¶¯»¯µÄ²Ù×÷£¬¼òµ¥ÓÖʵÓ㬵«ÊÇÉæ¼°Âß¼¿ØÖƺÍ
×Ö·û´®´¦Àíʱ£¬¿´µ½ÄÇif/fi£¬case£¯esac……»¹ÓйÅÀë¹Å¹ÖµÄ²¼¶ûÅжυ…»¹Óи´ÔÓ¶øÓÖÃû×ÖºÜÏì¶øÇÒºÜÀÏ×ʸñµÄsed¡¢awk……ÎÒ¾ÍÏ룬
ÔÚûÓзÇÒªÔÚshellÖÐ ......
Õâ¸öÊÇ1.10°æ±¾µÄ²ÂÊý×Ö£¬ËäÈ»´úÂë»ù±¾²»±ä£¬µ«ÊDZäµÄÊÇ˼ά·½Ê½£¬²»ÔÙÊÇÓÃÃæÏò¹ý³ÌµÄ·½·¨£¬¶ø¸ÃΪÓÃÀàÀ´ÊµÏÖ£¬±È½ÏÇ°ºóµÄ´úÂ룬ÕâÒ»¸ö¼ò½à¶àÁË£¬¶øÇÒ¸üÈÝÒ×Àí½â£¡
¸üУº
#1.0°æ±¾ÖеÄÌáʾÀàÐÍÊÇ£ºAABB£¬¼òµ¥µÄ˵¾ÍÊÇÏà¶ÔλÖõÄÊý×Ö¶ÔÁ˾ÍÏÔʾA£¬´íÁ˾ÍÏÔʾB£»
#ÏÖÔÚµÄÌáʾ¸ÄΪ£º0A4B¸ñʽ£¬Ò²¾ÍÊÇ˵²»ÌáʾÄǸöλÖõÄÊý× ......
ÔÚparamikoÖÐʹÓÃÓû§ÃûºÍÃÜÂëͨ¹ýsftp´«ÊäÎļþ£¬²»Ê¹ÓÃkeyÎļþ¡£
import getpass
import select
import socket
import traceback
import paramiko
def putfile():
#import interactive
# setup logging
paramiko.util.log_to_file('demo.log')
username = username
hostname = hostname
......
Python 3 Êä³öÖض¨ÏòʹÓÃC/C++
By:gddsky
Ä¿±ê
Ï£Íû½«Python 3µÄÊä³öÖض¨Ïòµ½×Ô¶¨ÒåµÄÊä³öÄ¿±ê¡£
ºËÐÄ
PythonʹÓÃsys.stdout¡¢sys.stderr×öÊä³öÄ¿±ê£¬Ö»ÒªÎÒÃÇÌæ»»ÕâÁ½¸öÖµ¾Í¿ÉÒÔÖض¨Ïòµ½ÎÒÃÇ×Ô¶¨ÒåÄ¿±ê¡£Ìæ»»µÄÖµµÄ¹æÔòÔÚPythonµÄÎĵµÖÐsys (module)µÄsys.stdoutÉÏÃæ˵Ã÷Ö»ÒªÌí¼ÓÒ»¸öwriteº¯Êý¾Í¿ÉÒÔ ......
python ÖÐminidom½âÎöxml
2009Äê06ÔÂ26ÈÕ ÐÇÆÚÎå 08:40
ÏÂÃæÖ»ÁгöһЩ³£Óõķ½·¨ÊôÐÔ£¬Èç¹ûÒª²é¿´¸ü¶àµÄ·½·¨£¬ ¿ÉÒÔÈ¥¿´ÎļþminidomÈçºÎʵÏֵġ£
»ñµÃDocument¶ÔÏó
·¨Ò»£º
import xml.dom.minidom as m_dom
doc1 = m_dom.getDOMImplementation().createDocument(None, "root1", None)
doc1.documentElement.toxml(e ......