python - Insert invisible unicode into MySQL using python3 but encountered duplicate -
when insert device data mysql(v5.5.6) using python(v3.2). encountered problem.
this device (it contains 3 unicode , blank space): '\u202d\u202d \u202d'
and device b (it blank space): ' '
the problem when insert device data mysql , error
duplicate entry 'activate_device-20151201-1-5740-01000p--- --' key 'primary'
i guess mysql has deal '\u202d'(a unicode reverse string maybe?).
how can simulate process in python3 mysql? how can avoid duplicate?
the expected result translate '\u202d\u202d \u202d' ' ' in python3.
please me.
there ambiguities here. want keep visible ascii characters or visible unicode characters ?
if want keep visible ascii characters, simple way use python inbuilt string module.
import string new_string = "".join(filter(lambda x:x in string.printable, original_string)) for specific usecase, space part of visible ascii - above convert '\u202d\u202d \u202d' , ' ' ' '
Comments
Post a Comment