-
update (160906): added an exe version - myqr.exe in qrcode_win
-
update (160908): added a web version - amazing-qrcode (made by Maras0830)
QR Code in Python
Python 二维码生成器
It can generate common qr-code, artistic qr-code (black & white or colorized), animated qr-code (black & white or colorized).
可以生成普通二维码、带图片的艺术二维码(黑白与彩色)、动态二维码(黑白与彩色)。
python myqr.py [-h]
[-v {1,2,3,...,40}]
[-l {L,M,Q,H}]
Words
-
Use argument
-h
for help.使用参数
-h
来获得使用帮助。
#1 url
python myqr.py https://github.com
-
Simplest way: Just input a URL or a sentence, then get your QR-Code in the current directory.
最简单的用法:在命令后输入链接或者句子作为参数,然后在程序的当前目录中产生相应的QR二维码图片。
#2 -v, -l
python myqr.py https://github.com -v 10 -l Q
-
The default length of a side of QR-Code depends on the numbers of words you input. And the default level (Error Correction Level) is H (the highest).
默认边长是取决于你输入的信息的长度,而默认纠错等级是最高级的H。
-
Customize size: If you want to control the length and the error-correction-level, use the
-v
and-l
arguments. The-v
representing the length is from a minimum of 1 to a maximum of 40. The-l
representing the error correction level is one of L, M, Q and H, where L is the lowest level and H is the highest.自定义尺寸:如果想要控制边长和纠错水平就使用
-v
和-l
参数。使用-v
来控制边长,范围是1至40,数字越大边长越大;使用-l
来控制纠错水平,范围是L、M、Q、H,从左到右依次升高。
python myqr.py [-h]
[-v {1,2,3,...,40}]
[-l {L,M,Q,H}]
[-p picture_file]
[-c]
[-con contrast]
[-bri brightness]
Words
-
arguments
-h
,-v
and-l
is as mentioned above.参数
-h
,-v
和-l
如上文述。
#1 -p
python myqr.py https://github.com -p github.jpg
-
The
-p
is to combine the QR-Code with the following picture which is in the same directory as the program. The resulting picture is black and white by default.参数
-p
用来将QR二维码图像与一张同目录下的图片相结合,产生一张黑白图片。
#2 -c
python myqr.py https://github.com -p github.jpg -c
-
The
-c
is to make the resulting picture colorized.加上参数
-c
可以使产生的图片由黑白变为彩色的。
#3 -con, -bri
python myqr.py https://github.com -p github.jpg [-c] -con 1.5 -bri 1.6
-
The
-con
flag changes the contrast of the picture - a low number corresponds to low contrast and a high number to high contrast. Default: 1.0.参数
-con
用以调节图片的对比度,1.0 表示原始图片,更小的值表示更低对比度,更大反之。默认为1.0。 -
The
-bri
flag changes the brightness and the parameter values work the same as those for-con
. Default: 1.0.参数
-bri
用来调节图片的亮度,其余用法和取值与-con
相同。
The only difference from Artistic QR-Code mentioned above is that you should input an image file in the .gif
format. The you can get your black-and-white or colorful qr-code.
动态二维码与上述的带图片的二维码的生成方法没什么区别,你只要采用 .gif
格式的图片即可黑白或者彩色的动态二维码。
-
Use a nearly square picture instead of a rectangle one.
请采用正方形近似正方形的图片
-
If the size of the picture is large, you should also choose a rightly large
-v
instead of using the default one.建议在图片尺寸大的时候使用
-v
的值也应该适当变大。 -
If part of the picture is transparent, the qr code will look like:
You can change the transparent layer to white, and then it will look like:
-
Numbers:
0~9
数字 0 到 9
-
Letters:
a~z, A~Z
大小写的英文字母
-
Common punctuations:
常用英文标点符号和空格
· , . : ; + - * / \ ~ ! @ # $ % ^ & ` [ ] ( ) ? _ { } | and (space)
You can use pip install -r requirements.txt
to ensure you have all dependencies.
可以使用命令pip install -r requirements.txt
来安装所有依赖的库。
- Linux, Python 3
- Windows, Python 3