Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

python shell½Å±¾(Ö÷Òª½²¹ÜµÀ²Ù×÷µÄÖ§³Ö)

ÕâÀïÌṩµÄÖ»ÊÇÒ»¸öÖ§³Ö¹ÜµÀµÄÃüÁîÖ´ÐнӿÚ, ÖÁÓÚ»ñÈ¡ÃüÁî, À©Õ¹×Ô¼ºµÄÃüÁî, ¾Í²»ÔÙ׸Êö.
¶ÔÓÚϵͳµÄÃüÁî, ¿ÉÒÔÖ±½Óµ÷ÓÃÕâ¸ö½Ó¿Ú·½·¨, ¶à¸öÃüÁîÖ§³Ö¹ÜµÀ²Ù×÷.  ·¢Éú´íÎóʱ, Òý·¢OSError.
1. Åжϴ«ÈëÃüÁîÊÇ·ñÊÇ×Ö·û´®ÀàÐÍ
2. ´«ÈëµÄÿ¸öÃüÁî.
3. ±éÀúËùÓÐÃüÁî.
4. »ñȡÿ¸öÃüÁîµÄÃüÁî¼°²ÎÊý
5. ¶¯Ì¬Ö´ÐÐPopen, ²¢½«·µ»ØÖµ·ÅÈëÁбípopensÖÐ
6. ¶¯Ì¬Ö´Ðй¹½¨µÄPopen, µÚÒ»¸öÖ»ÓÐstdin²»Ê¹ÓùܵÀ, ×îºóÒ»¸östdoutÖ¸¶¨Îªsys.stdout. ÆäÓàµÄ¶¼ÊÇPIPE
7. ±éÀúÈ¡³öPopen¶ÔÏó, ½«Ç°Ò»¸ö¶ÔÏóµÄstdoutдÈëµ½ºóÒ»¸ö¶ÔÏóµÄstdinÖÐ.
'''
Created on 2009-10-21
@author: selfimpr
@blog: http://blog.csdn.net/lgg201
@E-mail: lgg860911@yahoo.com.cn
@function: ²âÊÔ¹ýFreeBSDÏ¿ÉÒÔʹÓÃ. ÊÇÒ»¸öСÁ·Ï°, ×÷ÓÃÊǽ«ÏµÍ³ÃüÁî×÷Ϊ²ÎÊý´«Èë, Ö´ÐÐ. ½ÓÊܵIJÎÊýÖ§³Ö¹ÜµÀ²Ù×÷, ¹ÜµÀ²Ù×÷·ûʹÓÃ|.
'''
from sys import stdout
from subprocess import Popen, PIPE
def pipecmd(cmdstr):
if isinstance(cmdstr, str): # estimate if the argument is string
cmds = cmdstr.split('|') # split intact cmdstr to sigle command
cmds = [cmd.strip() for cmd in cmds] # strip space character
length = len(cmds)
popens = []
for index, cmd in enumerate(cmds): # each all the commands
cmd_args = cmd.split(' ')
cmd_args = [arg.strip() for arg in cmd_args]
try:
#################
# get all the instance of Popen
#################
popens.append(eval('Popen(cmd_args%(stdin)s%(stdout)s)' % \
{'stdin': '' if index == 0 else ', stdin=PIPE', \
'stdout': ', stdout=stdout' if index == length - 1 else ', stdout=PIPE'}))
except OSError, e:
print 'arises os error'
#################
# process pipe
#################
prev = None
for index, popenobj in enumerate(popens):
if not prev:
prev = popenobj
continue
popenobj.stdin.write


Ïà¹ØÎĵµ£º

PythonǶÈëC++Ïê½â(3)

¼Ìǰƪ¡¶Import Module¡·£¨http://blog.csdn.net/xiadasong007/archive/2009/09/02/4512797.aspx£©£¬¼ÌÐø·ÖÎöǶÈ벿·Ö»ù´¡ÖªÊ¶¡£Õâ´Î²»¶à˵£¬ÓÐʲôÎÊÌâ¼ÇµÃ¶à²éÓ¢ÎÄ×ÊÁÏ£¬¹úÄÚµÄÕâ·½ÃæÖªÊ¶ÉÙ
»¹ÊÇÀ´¿´´úÂ룬дÍêÎÒ¾Í˯¾õÁË~
 
#include "python/python.h"
#include <iostream>
using namespace std;
int ......

pythonÖеÄÁбíÅÅÐò²Ù×÷

 
 
 
Python lists have a built-in sort() method that modifies the list in-place and a sorted() built-in function that builds a new sorted list from an iterable.
There are many ways to use them to sort data and there doesn't appear to be a single, central place in the various man ......

Python±Ê¼Ç£¨7£©

  Ò»¸öPython½Å±¾µÄ¿ª·¢È«¹ý³Ì
ÎÊÌ⣺Íê³ÉÒ»¸ö¿ÉÒÔΪÎÒÃÇËùÓеÄÖØÒª³ÌÐò×ö±¸·ÝµÄ³ÌÐò¡£
²½Öè²ð½â£º
ÐèÒª±¸·ÝµÄÎļþºÍĿ¼ÓÉÒ»¸öÁбíÖ¸¶¨¡£
Îļþ±¸·Ý³ÉÒ»¸özipÎļþ¡£
zip´æµµµÄÃû³ÆÊǵ±Ç°µÄÈÕÆÚºÍʱ¼ä¡£
ÎÒÃÇʹÓñê×¼µÄzipÃüÁËüͨ³£Ä¬ÈϵØËæLinux/Unix·¢ÐаæÌṩ¡£WindowsÓû§¿ÉÒÔʹÓÃInfo-Zip³ÌÐò¡£×¢Òâ ......

Python±Ê¼Ç£¨8£©

PythonµÄÃæÏò¶ÔÏóÐÔÖÊ
ÀàºÍ¶ÔÏóÊÇÃæÏò¶ÔÏó±à³ÌµÄÁ½¸öÖ÷Òª·½Ãæ¡£Àà´´½¨Ò»¸öÐÂÀàÐÍ£¬¶ø¶ÔÏóÕâ¸öÀàµÄ ʵÀý ¡£ÕâÀàËÆÓÚÄãÓÐÒ»¸öintÀàÐ͵ıäÁ¿£¬Õâ´æ´¢ÕûÊýµÄ±äÁ¿ÊÇintÀàµÄʵÀý£¨¶ÔÏ󣩡£
 
ÐèҪעÒâµÄÊÇ£¬ÔÚPythonÖУ¬¼´±ãÊÇÕûÊýÒ²±»×÷Ϊ¶ÔÏó£¨ÊôÓÚintÀࣩ¡£ÕâºÍC++¡¢Java£¨1.5°æÖ®Ç°£©°ÑÕûÊý´¿´â×÷ΪÀàÐÍÊDz»Í¬µÄ¡£Í¨¹ ......

Python±Ê¼Ç£¨10£©

PythonÖеÄÒì³£
 
µ±ÄãµÄ³ÌÐòÖгöÏÖijЩÒì³£µÄ×´¿öµÄʱºò£¬Òì³£¾Í·¢ÉúÁË¡£
 
Ò».´¦ÀíÒì³£
ÎÒÃÇ¿ÉÒÔʹÓÃtry..exceptÓï¾äÀ´´¦ÀíÒì³£¡£ÎÒÃǰÑͨ³£µÄÓï¾ä·ÅÔÚtry-¿éÖУ¬¶ø°ÑÎÒÃǵĴíÎó´¦ÀíÓï¾ä·ÅÔÚexcept-¿éÖС£
ÀýÈç:
#!/usr/bin/python
# Filename: try_except.py
import sys
try:
s = raw_input('E ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ