Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python mechanize:提交带有文件(图像)的表单?_Python_Image_Browser_Mechanize - Fatal编程技术网

Python mechanize:提交带有文件(图像)的表单?

Python mechanize:提交带有文件(图像)的表单?,python,image,browser,mechanize,Python,Image,Browser,Mechanize,有一个表单具有以下控件(它是一个上载图像控件) 我试过了 br.form['profile_image'] = open("img.jpg") 但是,我得到了错误 File "/usr/local/lib/python2.6/dist-packages/mechanize-0.2.4-py2.6.egg/mechanize/_form.py", line 2784, in __setitem__ raise ValueError(str(e)) ValueError: val

有一个表单具有以下控件(它是一个上载图像控件)

我试过了

   br.form['profile_image'] = open("img.jpg")
但是,我得到了错误

  File "/usr/local/lib/python2.6/dist-packages/mechanize-0.2.4-py2.6.egg/mechanize/_form.py", line 2784, in __setitem__
    raise ValueError(str(e))
ValueError: value attribute is readonly
这样做:

br.form.add_file(open(FILENAME), 'text/plain', FILENAME)
br.form.set_all_readonly(False)
  File "/usr/local/lib/python2.6/dist-packages/mechanize-0.2.4-py2.6.egg/mechanize/_form.py", line 2784, in __setitem__
    raise ValueError(str(e))
ValueError: value attribute is readonly
br.form.add_file(open(FILENAME), 'text/plain', FILENAME)
br.form.set_all_readonly(False)