我通过网络表单提交了一个文件名,并让cherrypy接收这个文件名并打开它进行处理。我在这里遇到的问题是,文件何时包含“&“我发现以下错误。 我删除“&;”时没有问题从文件名
文件名:
invoicing - SP30075306 Heidelberg Dust & Dropper.xlsm
Python代码:
reload(sys)
sys.setdefaultencoding('utf8')
@cherrypy.expose
def cost_breakdown(self, **mate):
print mate['file'].encode('UTF8')
offer_path = os.path.join('C:/Users/rihanio/Dropbox/Projects/Python_code/work/gateway/Temp_Project_Files/temp_invoicing', mate['file'].encode('UTF8'))
打印输出错误:
invoicing - SP30075306 Heidelberg Dust
[Errno 2] No such file or directory: u'C:/Users/rihanio/Dropbox/Projects/Python_code/work/gateway/Temp_Project_Files/temp_invoicing\invoicing - SP30075306 Heidelberg Dust '
我通过在发送到python之前在webform端对文件名进行编码来解决这个问题
相关问题 更多 >
编程相关推荐