My code needs to be compatible with both Python 2.x and 3.x versions. I am getting both string as input to my function, and I need to do some manipulation on those:
if len(str1) > 10: str1 = str1[:10] +'...'if six.PY3: return ' : '.join((str1, str2))
For Python 2.x, the above join is giving error:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 0: ordinal not in range(128)
What is the cleaner way of handling such cases for all versions of 2.x and 3.x?As both the string are input to my code, I need to ensure that even if either of these strings contain UTF-8 characters, they should be joined properly.
Declaration : I am very new to Python.