Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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 PIL ÅúÁ¿´¦Àí´¦ÀíͼƬ

¿Í»§¸øÒ»¶ÑͼƬҪ´«µ½ºǫ́£¬Í¼Æ¬Ì«´óÁË£¬ÉÏ°ÙÕÅͼÓÃphotoshop¸ÄÌ«Âý£¬¾ÍÏëµ½ÓÃpythonд¸ö¼òµ¥µÄÅú´¦Àí¡£¹¦Äܼòµ¥¾ÍÊÇ°Ñԭͼ°´±ÈÀýËõС£¬´úÂë¸ü¼òµ¥ 20¶àÐС£
# -*- coding: cp936 -*-
import Image
import glob, os
#ͼƬÅú´¦Àí
def timage():
for files in glob.glob('D:\\1\\*.JPG'):
filepath,filena ......

Python±Ê¼Ç£¨5£©

Ä£¿é
 
Ò».¼ò½é
Ä£¿é»ù±¾ÉϾÍÊÇÒ»¸ö°üº¬ÁËËùÓÐÄ㶨ÒåµÄº¯ÊýºÍ±äÁ¿µÄÎļþ¡£ÎªÁËÔÚÆäËû³ÌÐòÖÐÖØÓÃÄ£¿é£¬Ä£¿éµÄÎļþÃû±ØÐëÒÔ.pyΪÀ©Õ¹Ãû¡£
 
ÀýÈ磺
 
#!/usr/bin/python
# Filename: using_sys.py
import sys
print 'The command line arguments are:'
for i in sys.argv:
print i
print '\n ......

pythonµÄwiki ÁÐ×Ó.

#coding=utf-8
from newtest.wiki.models import WiKi
from django.template import loader, Context
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render_to_response

def index(request, pagename=""):
"""ÏÔʾÕý³£Ò³Ã棬¶ÔÒ³ÃæµÄÎÄ×Ö×öÌØÊâµÄÁ´½Ó´¦Àí"""
......

Python±Ê¼Ç£¨8£©

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

python֮ǿ´óµÄÈÕ־ģ¿é¡¾×ª¡¿

1.¼òµ¥µÄ½«ÈÕÖ¾´òÓ¡µ½ÆÁÄ»

import
logging

logging.
debug(
'This is debug message'
)
logging.
info(
'This is info message'
)
logging.
warning(
'This is warning message'
)
 
ÆÁÄ»ÉÏ´òÓ¡:

WARNING:root:This is warning ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ