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

python¶ÁÎı¾Êý¾Ý

ÓÐÒ»¸öÎı¾ test.txt  Àï±ßÈ«ÊÇÊý¾Ý£¬ÅÅÁиñʽ»¯ÈçÏ£º

1 2 3
4 5 6
7 8 9

ÔõôÓÃpython¶ÁÈ¡¸ÃÎı¾²¢½«Ã¿ÐÐÈý¸öÊý×ÖÏà¼Ó£¬×îºóÒÔÎı¾ out.txt Êä³ö½á¹û£¬±ÈÈ磺
1+2+3=6
4+5+6=15

-------
ÎÒ×Ô¼º¹¹½¨ÁËÒ»¸öº¯Êý def sum(a,b,c): return a+b+c
Ïë¶ÁÈ¡Ò»ÐÐÊý¾Ý·Ö±ð¸³¸øa£¬b£¬c  È»ºóµ÷Óú¯ÊýµÃ³ö½á¹û£¬Ö®ºóÑ­»·¶ÁȡÿÐв¢¼ÆËã½á¹ûÊä³ö¡£

×Ô¼º¸Õ¸Õѧϰpython£¬²»ÖªÈçºÎ¶ÁÈ¡Îı¾ºó·Ö±ð½«ÊýÖµ¸³¸øa£¬b£¬c  Çë¸ßÊÖÖ¸µãÒ»ÏÂ




¸øÐÂÊÖ½âÊÍһϰɣ¬±Ï¾¹ÎÒÒ²ÊÇ´ÓÐÂÊÖ¹ýÀ´µÄ
ÒÔµÚÒ»ÐÐΪÀý£º
'+'.join(i.split()) + '=' + str(reduce(operator.add, map(lambda x:int(x), i.split())))
½âÊÍÈçÏ£º
--Ç°°ë²¿·Ö£º
i                  Ϊ'1 2 3'
i.split()          Ϊ['1', '2', '3']
'+'.join(i.split()) Ϊ'1+2+3'
--ºó°ë²¿·Ö£º
lambda x:int(x)    ÄäÃûº¯Êý£¬½«'1'ת»»ÎªÊý×Ö1
map(lambda x:int(x), i.split()) ÄÚÖõÄÓ³É亯Êý£¬¶Ôi.split()µÄÿ¸öÔªËØÓÃÇ°ÃæµÄº¯Êý×÷Ó³Éä
                        ½á¹ûΪ[1,2,3]
reduce(operator.add, map(lambda x:int(x), i.split())) Ò»¸öÐÂÊÖ²»Ì«ÈÝÒ׶®µÄÄÚÖú¯Êý£¬Ê±¼ä¹Øϵ£¬LZ×Ô¼º¿´Êé°É£¬Ëü¾ÍÊǶԸոÕ[1,2,3]×÷ÀÛ¼Ó£¬½á¹ûΪ10

*************************************************


Ïà¹ØÎÊ´ð£º

PythonÖÐÎÄ´¦Àí£¬Íê³É¹¦ÄܵÄʵÓû¯

±¾ÎÄÕª×Ô¡¶¿É°®µÄPython¡·¡°¹âÅ̹ÊÊ¡±CDay-1 ʵÓû¯ÖÐÎÄ¡£
[img]http://t.douban.com/mpic/s3901817.jpg[/img]
CDay-1 ʵÓû¯ÖÐÎÄÖÐÎÄ´¦Àí£¬Íê³É¹¦ÄܵÄʵÓû¯
ÄãÅöµ½99%µÄÎÊÌ⣬ÆäËûÈË֮ǰÒѾ­Óöµ½¹ýÁË£¬Ë ......

pythonÕýÔò±í´ïʽ ÈçºÎÈ¡³öÒÔÏÂ×Ö·û´® ¶àл

s='aaa111aaa,bbb222,333ccc,444ddd444,555eee666,fff777ggg'
ÓÃÕýÔò±í´ïʽȡ³ö Ç°ºó×ÖĸÏàͬµÄÊý¾Ý ½á¹ûÈçÏÂ:
111 ddd
лл~
Python code:

import re
s='aaa111aaa,bbb222,333ccc,444ddd444,555eee666,ff ......

IIS 7 python 2.6 cgi ÎļþÉÏ´«ÎÊÌâ

ÎÒÿ´ÎÉÏ´«µÄÎļþ¶Áµ½µÄÊý¾Ý¶¼²»ÕýÈ·¡£2M µÄͼƬ¶ÁµÃ10¶àK ¡£¡£ÄÄλ´óÏÀ¿ÉÒÔ°ï°ïÎÒ°¡¡£
#!D:\ProgrammerTools\python26\python.exe
#encoding=utf-8
import cgitb
import os
cgitb.enable()
import cgi,urllib ......

³ÏÕÐPython³ÌÐòÔ±²ÎÓë¼ÆËã»úÊé¼®³ö°æ

ÓźñµÄ¸å³ê£¬³ÏÕÐPython¼¼ÊõÈËÔ±²ÎÓë¸÷ÖÖ¼¼ÊõÊé¼®³ö°æ¡£ 
ͨ¹ý¸ÃÊé¼®£¬×÷Õß¿ÉÒԵõ½Èçϱ¨³ê£º 
1¡¢·áºñµÄ¸å³ê¡£ 
2¡¢Êé¼®Öø×÷µÄÊðÃûȨ¡£ 
3¡¢¶Ô×÷ÕߺÍÊé½øÐÐÐû´«£¬Ìá¸ß×÷ÕßÔÚ¼¼ÊõȦ×ÓÀ ......

Çë½Ì¸ßÊÖ¹ØÓÚpython¿ª·¢webµÄÎÊÌâ¡£

ÇëÎʸßÊÖ£¬ÈçºÎÓÃpython¿ª·¢webʱ£¬²»ÓÃcssÑùʽ±íÖ±½ÓÓÃpythonÓïÑÔʵÏÖÍøÕ¾Ò³ÃæЧ¹ûÔÚ800*600¡¢1200*1600¡¢1024*768µÈÏÔʾ·Ö±æÂʵÄÏÔʾÆ÷ÉÏÕý³£ÏÔʾÄØ£¿£¿
²»Ã÷°×ÄãÒª×öʲô...

1. web¿ª·¢, ʼÖÕ´«Ë͹ýÀ´, ä ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ