Python Unicode±àÂëÎÊÌâ
ǰ¼¸Ìì¸Õ¸Õ½Ó´¥Python£¬ºÃ¶àÎÊÌâ²»Ã÷°×
´úÂëÈçÏ£¬¿ÉÒÔÕý³£Êä³ösheetname.Èç¹û°Ñ±àÂ뷽ʽ¸Ä³Éutf16¾Í»á±¨´í
TypeError: compile() expected string without null bytes
ÇëÎÊÊÇΪʲô£¿
»¹ÓÐÊä³öµØÄÚÈÝÊÇ[u'10069', u'\u53f0\u5317\u5e02', u'\u4e2d\u6b63\u5340', u'\u4e2d\u83ef\u8def', u'\u4e2d\u83ef\u8def\uff12\u6bb5', u'\u4e2d\u83ef\u8def\u4e8c\u6bb5', u'\u3000', u'1\u865f', u'1\u865f']
Ϊʲô²»ÊÇ·±Ìå×Ö·û£¿
»¹ÓÐÔÚWindowsÏÂʹÓÃPython£¬¡°#!/usr/bin/python¡±ÕâÒ»¾äÊDz»ÊǾͲ»Ó¦¸ÃÕâÑùд£¿
#!/usr/bin/python
# -*- coding: utf8 -*-
# Filename : xlTest.py
import xlrd
workbook = xlrd.open_workbook(u'C:\Documents and Settings\Administrator\×ÀÃæ\TWN_ID\TWN_RdSt_5.xls')
print workbook.sheet_names()
sheet = workbook.sheet_by_name(u'Rd_St')
for rownum in range(sheet.nrows):
print sheet.row_values(rownum)
Á˽âÁË£¬Ð»Ð»
Ïà¹ØÎÊ´ð£º
ÔÚÎı¾ÎļþÖÐÆ¥ÅäÏî°üº¬ÖÐÎÄ
ÈçÄÚÈÝΪ£ºgamename=ÖÐÎÄ
key=ÌìÏÂ
Îı¾ÎļþµÄ±àÂëµÄÎļþΪutf-8
python´úÂëÈçÏ£º
# -*- coding:UTF-8 -*-
contents=open(from_pa ......
#! c:\python26
# Filename: backup_ver1.py
import os
import time
source=[r'C:\test', r'C:\test1']
target_dir='D:\\back\\'
target=target_dir+time.strftime('%Y%m%d%H%M%S')+'.zip'
zip_command=" ......
×î½üÃÔÉÏÁËPython£¬ÔÚ˼¿¼ÔõÑùÓÃPythonд¸ö³ÌÐòʵÏÖ¶ÔÖ¸¶¨ÍøÂç¶Ë¿ÚµÄÊý¾Ý°üµÄץȡºÍ½âÎö£¬¿ÒÇë¸ßÊÖÖ¸½Ì£¡£¡
ÄãºÃ£¡
Ê×ÏÈ£¬ÊµÏÖ²¶°üµÄ¹¦ÄÜÐèҪʹÓÃwincap£¨windowsÏ£©£¬»òÕßlibpcap£¨LinuxÏ£©¡£
¶øPythonÌṩÁ ......
Traceback (most recent call last):
File "C:\test.py", line 80, in <module>
cur.execute("update userdata set kb=0 where strAccountID='%s'" % name)
......
תÌû£º
import sys
from wxPython.wx import *
from wxPython.lib import newevent
DispatchEvent, EVT_DISPATCH = newevent.NewEvent()
class GenericDispatchMixin:
def __init__(self):
......