Is there a way to convert true of type unicode to 1 and false of type unicode to 0 (in Python)?
true
unicode
false
For example: x
x
Use int() on a boolean test:
int()
x = int(x == 'true')
int() turns the boolean into 1 or 0. Note that any value not equal to 'true' will result in 0 being returned.
1
0
'true'