使用Python过程中报错
python 报错:a bytes-like object is required, not 'str'代码如下:import csvimport base64
def image_to_base64():
'''封装把图片转换为base64编码格式'''
o = open(r'E:\Jmeter\1.jpg', 'rb')
base64_data = base64.b64encode(o.read())
s = base64_data.decode()
return ("data:image/png;base64,%s"%s)
def base64_write_csv():
'''把生成的base64写入CSV文件'''
f = open(r'E:\Jmeter\image.csv', 'wb')
csv_writer = csv.writer(f)
csv_writer.writerow(['image'])
csv_writer.writerow()
f.close()
if __name__ == '__main__':
base64_write_csv()出现:求问是咋回事?
变量类型不对 写的不对 变量检查弄一下
页:
[1]