# -*- coding: utf-8 -*-
import qrcode
import os,sys
def parseArgs(sys_args=sys.argv):
apk_path = (lambda x: len(x)!=1 and x[1] or 'help')(sys_args)
# 分离所在目录和文件名
[dirname,filename]=os.path.split(apk_path)
# 分离扩展名
[fname,fename]=os.path.splitext(apk_path)
return dirname,filename,fname,fename
def QrCode(path):
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_L,
box_size=5,
border=2,
)
apk_path = path[0]+'/'+path[1]
qr.add_data(apk_path)
qr.make(fit=True)
img = qr.make_image()
img.save('%s.png' % (path[2].split('/')[-1]))
if __name__ == '__main__':
path_list = list(parseArgs())
QrCode(path_list)