Version: Python 2.7
I'm reading values from a Unicode CSV file and looping through to find a particular product code - a string. The variable p
is from the CSV file.
sku = '1450' # sku can contain spaces.
print p, '|', sku
print p == '1450'
print binascii.hexlify(p), '|', binascii.hexlify(sku)
print binascii.hexlify(p) == binascii.hexlify(sku)
print 'repr(p): ', repr(p)
which results in
1450 | 1450
False
003100340035003000 | 31343530
False
repr(p): '\x001\x004\x005\x000\x00'
Q1. What is a future-proof way (for version 3, etc.) to successfully compare?
Q2. The Unicode is little-endian. Why have I got 00
at both ends of the Unicode hex?
Note: attempts at converting to Unicode - u'1450'
- don't seem to have any affect on the output.
Thanks.