生成二维码
def make_qrcode(data: str, path: str):
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_L,
box_size=10,
border=4
)
qr.add_data(data)
qr.make(fit=True)
img = qr.make_image(fill_color="black", back_color="white")
img.save(path)
pandas 读取 excel
data = pd.read_excel(file_name)
data.replace(np.nan, None, inplace=True)
obj_list = data.apply(lambda x: tuple(x), axis=1).values.tolist()
excel 插入本地图片
workbook = xlsxwriter.Workbook('images_bytesio.xlsx')
worksheet = workbook.add_worksheet()
filename = 'logo.png'
image_file = open(filename, 'rb')
image_data = BytesIO(image_file.read())
image_file.close()
worksheet.insert_image('B8', filename, {'image_data': image_data})
workbook.close()
excel 插入远程图片
workbook = xlsxwriter.Workbook('images_bytesio.xlsx')
worksheet = workbook.add_worksheet()
url = 'http://admin.msh-dev.sugonup.com//media/default/2023/09/0a/2a463b35_7828_small.jpg'
image_data = BytesIO(urlopen(url).read())
worksheet.insert_image('B2', url, {'image_data': image_data})
workbook.close()
标签:qr,python,worksheet,image,excel,二维码,workbook,data
From: https://www.cnblogs.com/guanchaoguo/p/17723099.html