2007年07月30日 星期一 15:28
ÔÚgoogleµÄcomp.lang.pythonÕÒµ½ÁËһЩ¾Ë÷,»ù±¾M×ãÎÒµÄÒªÇó.´ú´aÈçÏÂ: 01. import win32com.client 02. 03. 04. def AppendChunk(field, fileName): 05. try: 06. file = open(fileName, 'rb').read() 07. binaryBuffer = buffer(file) 08. 09. mstream = win32com.client.Dispatch(r'ADODB.Stream') 10. mstream.Type = adTypeBinary 11. mstream.Open() 12. mstream.Write(binaryBuffer) 13. mstream.Position = 0 14. 15. objRS.AddNew() 16. objRS.Fields.Item(field).Value = mstream.Read() 17. objRS.Fields.Update() 18. except: 19. print 'error' 20. 21. 22. def GetChunk1(field, fileName): 23. try: 24. val = objRS.Fields.Item(field).Value 25. 26. mstream = win32com.client.Dispatch(r'ADODB.Stream') 27. mstream.Type = adTypeBinary 28. mstream.Open() 29. mstream.Write(buffer(val)) 30. mstream.Position = 0 31. mstream.SaveToFile(fileName) 32. except: 33. print 'error' 34. 35. 36. def GetChunk2(field, fileName): 37. try: 38. fl = open(fileName, 'wb+') 39. val = objRS.Fields.Item(field).Value 40. if val: 41. fl.write(val) 42. except: 43. print 'error' 44. finally: 45. fl.close() Èç¹ûÄúÓиüºÃµÄ·½·¨,ÕÙn½Ì! ----- ÔʼÓʼþ ---- ·¢¼þÈË£º ÍôÎĽø <wjawon在yahoo.com.cn> ÊÕ¼þÈË£º python-chinese在lists.python.cn ÒÑ·¢ËÍ£º 2007/7/17(Öܶþ), ÉÏÎç10:25:44 Ö÷Ì⣺ [python-chinese] »Ø¸´£º pywin32ÖÐÈçºÎ´æÈ¡¶þßMÖÆ´ó¦Ïó ÕÒµ½ÁËGetChunkºÍAppendChunk,ßÊDz»ÖªµÀÔõôÓÃ! ÕlÄÜÖ¸½Ì? 01. import pythoncom 02. import win32com.client 03. 04. try: 05. objConn = win32com.client.Dispatch(r'ADODB.Connection') 06. objConn.Open(r"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:/db1.mdb") 07. 08. objRS = win32com.client.Dispatch(r'ADODB.Recordset') 09. objRS.Open('SELECT id,photo FROM [user]',objConn,1,3) 10. objRS.MoveFirst() 11. 12. sz = objRS.Fields.Item('photo').ActualSize 13. objRS.Fields.Item('photo').GetChunk(sz) 14. #???????????? 15. except pythoncom.com_error, (hr, msg, exc, n): 16. print 'com error' ----- ÔʼÓʼþ ---- ·¢¼þÈË£º ÍôÎĽø <wjawon在yahoo.com.cn> ÊÕ¼þÈË£º python-chinese在lists.python.cn ÒÑ·¢ËÍ£º 2007/7/16(ÖÜÒ»), ÏÂÎç4:06:10 Ö÷Ì⣺ [python-chinese] pywin32ÖÐÈçºÎ´æÈ¡¶þßMÖÆ´ó¦Ïó ս̸÷λ,ÔÚpywin32ÖÐÈçºÎ´æÈ¡¶þßMÖÆ´ó¦Ïó(ADO)? ÒÔÇ°ÔÚCÖÐÓÃField¦ÏóµÄGetChunkºÍAppendChunk·½·¨,ÔÚpywin32ÖÐÓÐ]ÓÐîËƵķ½·¨? ¬FÔÚÎÒÒª¢AutoCADÎļþ(»òeµÄÎļþ)´æÈë/×x³öµþì, ÄÄλÓпÕÄܽoÎÒÒ»Ô´´aíÕfÃ÷,±ÈÈç: def AppendChunk(FieldName,FileName): ... def Getchunk(FieldName): ... ÖxÖx! (win2k + python2.5 + pywin32-210) ÑÅ»¢Ãâ·ÑÓÊÏä3.5GÈÝÁ¿£¬20M¸½¼þ£¡ _______________________________________________ python-chinese Post: send python-chinese在lists.python.cn Subscribe: send subscribe to python-chinese-request在lists.python.cn Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn Detail Info: http://python.cn/mailman/listinfo/python-chinese ÇÀ×¢ÑÅ»¢Ãâ·ÑÓÊÏä3.5GÈÝÁ¿£¬20M¸½¼þ£¡ ___________________________________________________________ ÇÀ×¢ÑÅ»¢Ãâ·ÑÓÊÏä3.5GÈÝÁ¿£¬20M¸½¼þ£¡ http://cn.mail.yahoo.com -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070730/9aa168cf/attachment-0001.htm
Zeuux © 2025
京ICP备05028076号