<p>我想在python文件中存储foto数据。但是我的文件中有一些奇怪的字符,所以这个文件不能正常打开。
我要做的是在将数据保存到文件中之前将其从数组中删除:</p>
<pre><code>def save_foto(self):
""" Save foto data to a file """
self.data_aux = ''
last = 0
self.data_list = list(self.vFOTO)
for i in range(0,len(self.vFOTO)):
if(self.vFOTO[i]=='\x90' and self.vFOTO[i+1]=='\x00' and self.vFOTO[i+2]=='\x00' and self.vFOTO[i+3]=='\x00'
and self.vFOTO[i+4]=='\x00' and self.vFOTO[i+5]=='\x00' and self.vFOTO[i+6]=='\x00' and self.vFOTO[i+7]=='\x00'
and self.vFOTO[i+8]=='\x00' and self.vFOTO[i+9]=='\x00'):
aux1=''.join(map(chr,self.data_list[last:i]))
self.data_aux = self.data_aux+aux1
i=i+10
last=i
</code></pre>
<p>但我得到了错误</p>
<blockquote>
<p>"TypeError: an integer is required (got type str)" on line aux1=''.join(map(chr,self.data_list[last:i])). </p>
</blockquote>
<p>有人能帮我解释一下发生了什么事吗?
提前谢谢。在</p>