我正在尝试从数据库读取二进制列,然后将内容写入文件。我编写了以下代码,但出现以下错误:
UnicodeEncodeError: 'ascii' codec can't encode character '\xa0' in position 1015267: ordinal not in range(128)
下面是我的代码:
with open(getattr(settings,'DIR')+file+'.js', 'w') \
as filetowrite:
filetowrite.write(str(bytes(col.data), 'utf-8'))