Python Êý×ÖÓë×Ö·û´®Á¬½ÓÎÊÌâ
¶¨ÒåÏÂÃæÕâÑùÒ»¸öº¯Êý£¬½«excel±í¸ñÖÐÁ½¸öµ¥Ôª¸ñµÄÄÚÈÝÁ¬³ÉÒ»¸ö×Ö·û´®£¬µ«ÊÇÈç¹ûÇ°Ò»¸öµ¥Ôª¸ñµÄÄÚÈÝÊÇÊý×Ö£¬±ÈÈçÊÇ¡°1¡±£¬ºóÒ»¸öµ¥Ôª¸ñµÄÊÂ×Ö·û´®£¬¾Í»á±¨´íunsupported operand type(s) for +=: 'float' and 'unicode'¡£def GetSection(index):
section = sheet.cell_value(index,6)
section += sheet.cell_value(index,8)
return section
Èç¹ûÔÚ ¡°+=¡± ²Ù×÷Ç°Ãæ¼ÓÒ»¾ä str(section)
Óֻᱨ´íascii' codec can't encode character u'\u5168' in position 0: ordinal not in range(128)
ÇëÎÊÈçºÎ½â¾ö
ÀûÓÃunicode À´Ç¿ÖÆת³É×Ö·û´®ÊÔÊÔ
section += unicode(sheet.cell_value(index,8))
ËäÈ»PythonÊǶ¯Ì¬ÓïÑÔ£¬µ«PythonÖеĶÔÏóÊÇÇ¿ÀàÐ͵ģ¬int Óë strÐ͵ĶÔÏóµ±È»²»ÄÜÌí¼Ó¡£
return ('%s%d' %(sheet.cell_value(index,6),sheet.cell_value(index,8)))
Õâ¸ö¿ÉÒÔ²»
Õâ¸öÓ¦¸Ã¿ÉÒÔ°É¡£²»¹ý£¬Èç¹û±àÂë²»¶ÔµÄ»°£¬»¹ÊÇ»á³öÏÖÂÒÂëµÄ¡£
ѧϰ....
³ÌÐòÖбàÂëҪͳһŶ
²»È»ÒÔºóºÜÂé·³µÄ
ÕâÊǸö±àÂëÎÊÌ⣬EXCELÀï×Ö·û´®¶¼ÊÇUNICODE£¬Êý×Ö¾ÍÊÇÊýÖµÀàÐÍ£¬Á½¸ö±äÁ¿Ïà¼Ó֮ǰ£¬½«ÊýÖµÀàÐÍÇ¿ÖÆת»»ÎªUNICODEÀàÐͼ´¿É£¬¿´ÏÂÏà¹ØµÄ×ÊÁϾÍÐÐÁË
def InsertCode5(cursor,code,address,section):
t = (code,address,section,)
cursor.execute('insert into TBL_CODE_5 values (?,?,?)', t)
½â決ÁË£¬謝謝´ó¼ÒÖ§³Ö
Ïà¹ØÎÊ´ð£º
ѧϰpythonµÄ7±¾Êé
°üÀ¨6±¾chm£¬Ò»±¾pdf×ÊÁÏ
¶ÔѧϰpythonÓкܴóµÄ°ïÖú
http://download.csdn.net/source/619791
¾«ÐÄËѼ¯£¬²»Òª»ý·Ö£¬ÄóöÀ´·ÖÏí
лл¥Ö÷£¬ÐÁ¿àÁË~
lz ×îºÃ°ÑÊéÃûºÍ¼òµ¥½éÉܼÓÉ ......
ÄÄλǰ±²¿ÉÒÔ¸øÎÒ¸öPythonдµÄ¡¾¿ÉÔËÐеÄÔ´´úÂë¡¿£¬ÊµÏÖÒÔϹ¦ÄÜ£º
1.¶ÔÖ¸¶¨¶Ë¿ÚµÄ¼àÌý²¢½ØÈ¡¡¾Ö¸¶¨¡¿Êý¾Ý°ü
2.Äܶԡ¾×Ô¼º¶¨ÒåµÄ¡¿ÐÒé°ü½øÐнâÎö
Íò·Ö¸Ðл£¡£¡£¡
ÎÒÀ´¶¥ thy38
......
Traceback (most recent call last):
File "C:\test.py", line 80, in <module>
cur.execute("update userdata set kb=0 where strAccountID='%s'" % name)
......