问题描述
检查这段代码:
#now添加图像部分
part = writer.nextpart()
part.addheader(''Content-Transfer-Encoding'',''base64'')
body = part.startbody(''image / jpeg'')
base64.encode(open(''c:\ check.jpg'',''rb''),正文)
我收到以下错误:
IOError:[Errno 2]没有这样的文件或目录:''c:\\check.jpg''
args =(2,''没有这样的文件或目录'')
errno = 2
filename = r''c:\ checkk.jpg''
strerror =''没有这样的文件或目录''
不知道为什么我得到这样的错误,文件就在那里。也许错了
filetype?错误的阅读模式?
Check this piece of code:
#now add an image part
part = writer.nextpart()
part.addheader(''Content-Transfer-Encoding'', ''base64'')
body = part.startbody(''image/jpeg'')
base64.encode(open(''c:\check.jpg'', ''rb''), body)
I get the following error:
IOError: [Errno 2] No such file or directory: ''c:\\check.jpg''
args = (2, ''No such file or directory'')
errno = 2
filename = r''c:\check.jpg''
strerror = ''No such file or directory''
Dont know why im getting such error, the file is there. Perhaps wrong
filetype? Wrong read mode?
推荐答案
如果你输入print os.listdir(''c:/''),它会显示什么?在线上
开放之前? (你显然需要先导入操作系统。)
-Peter
What does it show if you put "print os.listdir(''c:/'')" on the line
before the open? (You''ll obviously need to import os first.)
-Peter
这可能是因为c:\是语法错误:
that''s probably because "c:\" is a syntax error:
文件"< stdin>",第1行
" c:\"
^
语法错误:EOL扫描单引号字符串
但是因为你得到了500错误相反,它确实听起来像你
忘了告诉我们*你是如何运行你的脚本...(服务器,平台,
python版本等) 。
< / F>
File "<stdin>", line 1
"c:\"
^
SyntaxError: EOL while scanning single-quoted string
but since you''re getting a "500 error" instead, it sure sounds like you
forgot to tell us *how* you''re running your scripts... (server, platform,
python version, etc).
</F>
这篇关于没有的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!