SHARE
TWEET

Create a a QR Code

steve-shambles-2109 Feb 27th, 2020 113 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. """
  2. Create a a QR Code
  3. By Steve Shambles Feb 2020
  4. stevepython.wordpress.com
  5.  
  6. requires:
  7. pip install pyqrcode
  8.  
  9. More info:
  10. https://pypi.org/project/PyQRCode/
  11. https://github.com/mnooner256/pyqrcode
  12. https://pythonhosted.org/PyQRCode/create.html
  13.  
  14. original source:
  15. https://www.geeksforgeeks.org/python-generate-qr-code-using-pyqrcode-module/
  16. """
  17.  
  18. import webbrowser
  19. import pyqrcode
  20. from pyqrcode import QRCode
  21.  
  22. # String to encode.
  23. # You can use a lot of links or lots of text if you want.
  24. qr_str = 'https://stevepython.wordpress.com/2020/02/27/how-to-create-qr-codes'
  25.  
  26. # Generate QR code.
  27. gen_code = pyqrcode.create(qr_str)
  28.  
  29. # Create and save the qr image.
  30. # You may want to experiment with the scale variable
  31. # to get your desired qrimage size.
  32. gen_code.svg('my_qr.svg', scale = 6)
  33.  
  34. # Display the qr image in default browser.
  35. webbrowser.open('my_qr.svg')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top