I'm using python 2.7 and want to print the value of a field I receive on my server through a form.
I type André for the field name.
name = request.form['stripeBillingName']
How do I print the value of the variable name in a readable encoding?
I want to print André and not Andr\xe9
In source header you can declare
#!/usr/bin/env python
# -*- coding: utf-8 -*-
....
After that you can use utf-8, which should give you your desirable format
name = request.form['stripeBillingName']
nameDec = name.decode('utf8')
print nameDec
You can also encode it however you want e.g:
nameEnc = nameDec.encode('cp1250')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With