Unwanted character in Excel Cell In Python

character, excel, ms-word, python

Solution

Try using `value.rstrip('\r\n')` to remove any carriage returns (`\r`) or newlines (`\n`) at the end of your string `value`.

Problem

I am facing an issue with setting a value of Excel Cell. I get data from a table cell in MS-Word Document(dcx) and print it on output console. Problem is that the data of the cell is just a word, "Hour", with no apparent other leading or trailing printable character like white-spaces. But when I print it using python's print() function, it shows some unexpected character, more like a small "?" in a rectangle. I don't know where does it come from. And when I write the same variable that holds the word, "Hour", to an Excel cell it shows a bold dot(.) in the cell. What can be the problem? Any help is much appreciated. I Am Using Python 3.2 And PyWin32 3.2 On Win7. Thanks.

Original source