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

Python ´¦Àíexcel²¢×ªÎªtable

ʹÓÃxlrd
À´
¶ÁÈ¡£¬xlrdµÄÏÂÔؼ°°²×°¿ÉÒԲο´:
Python
"xlrd" package for extracting data from Excel files
---------------------------------------------------------------------------------
#coding=utf-8
import xlrd
import os, types, datetime
#excel´æ·ÅĿ¼
dir = u'D:\\temp\\excel'
#Éú³Éhtml´æ·ÅĿ¼£¬ÐèÒªÊÂÏȽ¨Á¢
htmlroot = u'D:\\temp\\html'
#excel´Ó1899/12/31¼ÆËãʱ¼ä
__s_date = datetime.date(1899, 12, 31).toordinal() - 1
#¶Áȡʱ¼ä¸ñʽµÄµ¥Ôª
def getdate(date):
    if isinstance(date, float):
        date = int(date)
    d = datetime.date.fromordinal(__s_date + date)
    return d.strftime("%Y-%m-%d")
#±éÀúÎļþ¼Ð
for root, dirs, files in os.walk(dir):
    for file in files:
        #Éú³ÉexcelÎļþ·¾¶
        path = os.path.join(root, file)
        print u'converting...   ' + path
      
        book = xlrd.open_workbook(path) #´ò¿ªexcelÎļþ
      
        #±éÀúexcelÎļþÖеÄsheet
        for shn in range(book.nsheets):
            sh = book.sheet_by_index(shn)
            #ÅжϸñíÊÇ·ñΪ¿Õ
            if sh.nrows == 0:
                continue
          
            #ËÑË÷“·¾¶”ÁÐ
 &nbs


Ïà¹ØÎĵµ£º

ÓÃEclipse±àÒëÏòsqliteÊý¾Ý¿â²åÈëÊý¾ÝµÄpython³ÌÐò

½ñÌìÓöµ½ÁËÂé·³£º
      ÓÃEclipse±àÒëpythonÏòsqliteÊý¾Ý¿â²åÈëÊý¾Ý×ÜÊÇÌáʾ±àÂëµÄÎÊÌ⣬ÎÒÉèÖÃÁËEclipseµÄworkspaceÓÃutf-8±àÂ뻹ÊDz»ÐÐ
µ«ÊÇÓÃEclipseдµÄ³ÌÐò±£´æÔÙÓÃIDLE´ò¿ªÈ´ÄܱàÒ룬Ææ¹ÖÁË
ÎÒ¿¼Âǵ½¿ÉÄÜÊÇÅäÖõÄÔ­Òò£¬ÕÒÕÒ±éÁËËùÓеÄÅäÖ㬶¼Ã»ÓÐÎÊÌ⣬°üÀ¨¹¤³ÌÎļþ
×îºóÎÒÓÃxvi32´ò¿ ......

ÔÚubuntuÉϱàÒëvim²¢´øÓÐpythonÖ§³Ö

ubuntu10.05³öÀ´ÁËÕâÁ½ÌìÒ»Ö±ÔÚÕÛÌÚ£¬ÏÔʾwubiÎÞ·´Ó¦£¬È»ºó´ÓÓ²ÅÌ°²×°ÆÚ¼äÓÖÓöµ½grub´íÎóµÈÎÊÌâ¡£°²×°³É¹¦ºó¸ã¸öÖÐÎÄÊäÈë·¨¾ÍÀÏ°ëÌ죬×îºóʹÓÃPinyinÕâ¸ö»¹ËãºÃÓã¬ÓеãÏëËѹ·¾ÍÊÇûʲô´Ê¿â¡£×î¶ñÐĵĻ¹ÊÇvimµÄÎÊÌ⣬ÓÃapt-get install vim×°µÄvim²»Ö§³Öϵͳ¼ôÇа壬ֻºÃ´ÓÔ´´úÂë±àÒ룬¿ÉÊÇÎÒ³¢ÊÔÁ˺ܶà´Î×ÜÊÇûÓÐpythonÖ§ ......

ÓÃPythonÖ±½ÓдUTF 8Îı¾Îļþ

µ±ÎÒÃÇÕâÑù½¨Á¢Îļþʱ
f =
file('x1.txt', 'w')
f.write(u'ÖÐÎÄ')
f.colse()
Ö±
½Ó½á¹ûÓ¦¸ÃÊÇÀàËÆ
    f.write(u'ÖÐÎÄ')
UnicodeEncodeError: 'ascii'
codec can't encode characters in position 0-16: ordinal not in
range(128)
ÒªÖ±½Óд utf-8 ÎļþÔõô°ìÄØ?
import codecs
f = codecs. ......

python´¦ÀíXML

»ù±¾É϶¼ÊÇʹÓÃpythonÀ´½âÎöxmlÎļþµÄ¡£
±ÈÈçÎÒÒª½«ÄÚÈÝΪ
<?xml version="1.0" encoding="utf-8"?>
    <root>
        <book isbn="34909023">
            <author>
 &n ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ