Closed kayagoban closed 3 years ago
You can probably just write into a StringIO or BytesIO object to grab the string generated by print_ascii
See also #104
As @Fiona1729 mentioned, this can be achieved with:
import io
import qrcode
qr = qrcode.QRCode()
qr.add_data("Some text")
f = io.StringIO()
qr.print_ascii(out=f)
f.seek(0)
print(f.read())
Will add this example to the docs.
My application needs the ability to grab a string of ascii instead of having it printed to the screen. This change allows the print_ascii method to optionally return a string.