python-unicode

UnicodeDecodeError when trying to read docx file

南笙酒味 提交于 2020-06-22 13:20:49
问题 Error occurs when opening docx file using python 3 When I tried to run: file=open("jinuj.docx","r",encoding="utf-8").read() below error occured 319 # decode input (taking the buffer into account) 320 data = self.buffer + input --> 321 (result, consumed) = self._buffer_decode(data, self.errors, final) 322 # keep undecoded input until the next call 323 self.buffer = data[consumed:] UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 11: invalid start byte 回答1: python-docx can

Import all letters of an alphabet in a certain language in python

一世执手 提交于 2020-06-17 09:45:42
问题 Could it be possible to import all the possible letters (lowercase, uppercase, etc.) in an alphabet in a certain language (Turkish, Polish, Russian, etc.) as a python list? Is there a certain module to do that? Thanks & Best Regards Michael 回答1: Your question ties into a larger problem - how alphabets of certain languages are stored in a computer, how they are represented, and (eventually) how they can be retrieved in Python? I suggest you read: The Absolute Minimum Every Software Developer

String.maketrans for English and Persian numbers

人走茶凉 提交于 2020-02-21 11:57:11
问题 I have a function like this: persian_numbers = '۱۲۳۴۵۶۷۸۹۰' english_numbers = '1234567890' arabic_numbers = '١٢٣٤٥٦٧٨٩٠' english_trans = string.maketrans(english_numbers, persian_numbers) arabic_trans = string.maketrans(arabic_numbers, persian_numbers) text.translate(english_trans) text.translate(arabic_trans) I want it to translate all Arabic and English numbers to Persian. But Python says: english_translate = string.maketrans(english_numbers, persian_numbers) ValueError: maketrans arguments