有没有办法以编程方式将二进制文件转换为二维码?

Is there a way to turn binary into a QR code programmatically?

我有以下内容:

1 1 1 1 1 1 1   1   1   1 1   1     1 1 1 1 1 1 1 
1           1     1 1 1 1 1     1   1           1
1   1 1 1   1   1 1 1         1     1   1 1 1   1 
1   1 1 1   1   1 1 1   1   1 1     1   1 1 1   1 
1   1 1 1   1   1     1 1   1 1 1   1   1 1 1   1 
1           1       1 1   1     1   1           1 
1 1 1 1 1 1 1   1   1   1   1   1   1 1 1 1 1 1 1 
                    1   1     1 1                 
1 1 1 1     1   1   1 1 1 1   1 1 1     1 1 1   1 
    1         1     1   1 1 1   1     1   1       
1 1   1 1 1 1     1 1 1 1 1     1         1       
    1 1 1     1   1 1           1 1       1 1 1   
    1 1 1 1 1 1   1 1   1   1     1 1 1 1   1 1   
      1   1   1 1 1   1 1   1 1 1   1 1 1   1 1 1 
  1   1     1 1 1     1   1           1       1   
1   1 1 1 1     1   1 1     1         1       1 1 
    1   1 1 1 1 1   1   1   1   1 1 1 1 1   1 1   
                1   1       1 1 1       1 1 1   1 
1 1 1 1 1 1 1     1 1     1 1   1   1   1     1 1 
1           1     1   1   1 1 1 1       1         
1   1 1 1   1     1       1 1   1 1 1 1 1         
1   1 1 1   1   1 1 1             1 1   1 1   1 1 
1   1 1 1   1   1 1         1   1   1 1 1     1   
1           1   1     1 1 1 1     1       1 1     
1 1 1 1 1 1 1   1   1 1             1     1 1 1 1 

它不会扫描 QR 码 reader。有什么办法可以把它变成一个真正的二维码以便它可以扫描吗?

由于您似乎已经知道哪些方块要变黑哪些不变黑,您可以只使用 pillow to generate an image. You'll need to use ImageDraw and Image。你需要做的是:

from PIL import Image, ImageDraw
im = Image.new('1', (width, height), color=1) # Background white
draw = ImageDraw.Draw(im)
draw.point((x, y), 0) # Draw black

实际上我最终将我的文本编辑器的背景变成了白色,用两个 个字符 ██ 替换了所有 1 个字符,截屏,然后缩放缩小图片,使其不那么散开。

只是想为了完整起见我会添加它。