Invalid Mode Or Filename When Using Openpyxl In Python 2.7
I am trying to write something in an existing workbook with the openpyxl tools. But i am getting Err no 22 and dont know why. My Script looks like this : and this is the Console o
Solution 1:
In Python the \
is used in strings to escape characters. You can avoid this by using "raw strings" by prefixing with "r". So r'J:\Python_Script\book2.xls'
should work.
However, when working with paths it's most common to use the os.path
module to make sure this are correct.
dest_filename = os.path.join("J:", "Python_Script", "book2.xlsx")
This is invaluable when writing portable code.
Post a Comment for "Invalid Mode Or Filename When Using Openpyxl In Python 2.7"