pythonÖÐÎÄĿ¼
ÈçÓÐһ·¾¶"e:/software/²âÊÔ.txt"
ÐèҪͨ¹ýpyhon¶Á/д "²âÊÔ.txt"Îļþ£¬¿ÉÒÔ²ÉÓÃÏÂÃæµÄ·½·¨£º
ipath = "e:/software/²âÊÔ.txt"
uipath = unicode(ipath , "utf8")
È»ºóÓÃ"uipath"¾¹ý±àÂëºóµÄ·¾¶È¥open()¼´¿É¡£
ÏÂÃæÊÇÎÒÔÚÏîÄ¿ÖÐÓÃpython¶ÁдexcelµÄÒ»µãÌå»á(½â¾öÁ˶ÁÖÐÎÄÎļþÃûÎÊÌ⣬ÆäʵÖÐÎÄĿ¼·¾¶Ò²Ò»Ñù)£º
def transExcel( inPath ) :
excelApp = Dispatch("Excel.Application")
inWorkbooks = excelApp.Workbooks.Open( unicode( inPath, "utf8" ) )
#²âÊÔÏÂinWorkbooksÕâ¸ö¶«¶«ÓеØÖ·Ã´£¿
print "transExcel...",inWorkbooks
transExcel("e:/software/²âÊÔ.xls")
Ïà¹ØÎĵµ£º
Documentation for C's fopen():
---
r Open text file for reading. The stream is positioned at the beginning
of the file.
r+ Open for reading and writing. The stream is positioned at the
beginning of the file.
w Truncate file to zero length or create text file for writing. The
stream is posi ......
¹ØÓÚPython³ÌÐòµÄÔËÐУ¬Æäʵһ¸öPython³ÌÐò¾ÍÏ൱ÓÚÒ»¸öÓ¦ÓóÌÐò£¬Ëü²»ÐèÒª¾¹ý±àÒ룬ֻÐèÒªÓû§µçÄÔÉÏÃæ°²×°Python»·¾³¼´¿É¡£ÒªÔËÐÐÒ»¸öpy³ÌÐò£¬Ö±½ÓË«»÷Õâ¸öpyÎļþ¼´¿É¡£Ò»°ãÇé¿öÏ£¬Ã»ÓÐÌáʾÓû§ÊäÈë»ò¿ØÖÆÆÁÄ»ÏÔʾ£¬´ò¿ªÒ»¸öpyÎļþʱ»áͻȻÉÁÒ»ÏÂÂíÉϾÍÍ˳ö£¬ÕâÊÇÓÉÓÚ³ÌÐòÔËÐÐÒѾÍê³ÉÁË¡£ÈôÐèÒªÏÔʾ£¬ÔòÒªÌí¼ÓÒ» ......
Ê×ÏÈÒª¸ãÇå³þ£¬×Ö·û´®ÔÚPythonÄÚ²¿µÄ±íʾÊÇunicode±àÂ룬Òò´Ë£¬ÔÚ×ö±àÂëת»»Ê±£¬Í¨³£ÐèÒªÒÔunicode×÷ΪÖмä±àÂ룬¼´ÏȽ«ÆäËû±àÂëµÄ×Ö·û´®½âÂ루decode£©³Éunicode£¬ÔÙ´Óunicode±àÂ루encode£©³ÉÁíÒ»ÖÖ±àÂë¡£
decodeµÄ×÷ÓÃÊǽ«ÆäËû±àÂëµÄ×Ö·û´®×ª»»³Éunicode±àÂ룬Èçstr1.decode('gb2312')£¬±íʾ½«gb2312±àÂëµÄ×Ö· ......
ÔÚPythonÖÐÓÐÒ»¸ö·Ç³£ÖØÒªÒ²·Ç³£ºÃÓõÄÄ£¿ére£¬ÔÚimport reºó£¬¾ÍÄܹ»ÔÚPythonÖÐʹÓÃÕýÔò±í´ïʽ£¬Ô´ÓÚ´Ë´ÎÏîĿҪÓÃÕýÔò±í´ïʽ¶Ôhtml´úÂëÌáȡһ¶¨µÄ×Ö·û£¬ËùÒÔÔÚÕâÒ²¾ÍÓÃЩСÀý×ÓÀ´ÊìϤһÏÂÕýÔò±í´ïʽ
ÏÖÔÚ¾ÍÓÃ×î¼òµ¥µÄÀý×Ó
import re
s='<title>http://www.baidu.com</title>'
print re.findall(r'&l ......