我尝试遍历~3,000个网址列表并为其创建QR代码。在一列中我有URL,在另一列中,我有我想要的QR码文件名在输出为图像时的名称。
问题是转换为QR码的网址和我的文件名都被括在括号内。
例如:
URL Filename
www.abel.com Abel
出来:
URL in QR Code Filename of QR Code
[www.abel.com] [Abel]
到目前为止,这是我的代码:
import csv
import qrcode
import pandas as pd
df = pd.read_csv('QR_Python_Test.csv')
i = 1
x = df.iloc[[i]]
print(
x.QR_Code_Name.values)
for i in df.index:
z = df.iloc[[i]]
x = str(z.Link_Short.values)
qr = qrcode.QRCode(version=5, error_correction=qrcode.constants.ERROR_CORRECT_L,box_size=5,border=2,)
qr.add_data(x)
qr.make(fit=True)
img = qr.make_image()
file_name = str(z.QR_Code_Name.values) + ".png"
print('Saving %s' % file_name)
image_file = open(file_name, "w")
img.save(file_name)
image_file.close()
file.close()
以及一些示例数据:
URL Filename
www.apple.com Apple
www.google.com Google
www.microsoft.com Microsoft
www.linux.org Linux
感谢您的帮助, 我
答案 0 :(得分:1)
如果您的DataFrame包含正确的信息,则可以使用DataFrame.itertuples
还将功能分开
这样,你可以单独测试每一个
var list1 = [
"tag1 tag2 tag3",
"tag4 tag5 tag6",
"tag7 tag8 tag9",
"tag10 tag11 tag12",
"and so on...",
];
var i = 1;
window.onkeydown = function(keyPressed){
if(keyPressed.keyCode == 121){
document.getElementsByClassName("post-text-area")[0].value = "Count 1" + "/" + list1.length + "\n"+ list1[0];
document.getElementsByClassName("cmnt-btn")[0].click();
if(list1.length>1){
var repeat1 = setInterval(function start(){
if(i == list1.length-1){
clearInterval(repeat1);
}
document.getElementsByClassName("reply")[0].click();
document.getElementsByClassName("post-text-area")[1].value = "Count " + (i+1) + "/" + list1.length + "\n" + list1[i];
document.getElementsByClassName("cmnt-btn")[1].click();
i++;
},2000);i=1;}}
};