write data in Excel using python

Ian Kelly ian.g.kelly at gmail.com
Mon Nov 16 19:22:39 EST 2015


On Mon, Nov 16, 2015 at 11:20 AM, Michiel Overtoom <motoom at xs4all.nl> wrote:
>
> Hi,
>
>> On 16 Nov 2015, at 18:14, syedmwaliullah at gmail.com wrote:
>> For some reason it doesn't save the file.
>
> Did you get an error message?
>
>> excel.activeWorkbook.SaveAs ("c:\TurnData.xlsx")
>
> When you use backslashes in strings, don't forget to escape them:
>
>> excel.activeWorkbook.SaveAs("c:\\TurnData.xlsx")
>
> or use raw strings:
>
>> excel.activeWorkbook.SaveAs(r"c:\TurnData.xlsx")

You can also just use a forward slash:

excel.activeWorkbook.SaveAs("c:/TurnData.xlsx")

Windows happily accepts this.



More information about the Python-list mailing list