如何在特定的路径保存Xlsxwriter文件? [英] How to save Xlsxwriter file in certain path?

查看:1935
本文介绍了如何在特定的路径保存Xlsxwriter文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Xlsxwriter在哪里保存您创建的文件?可以指定要保存excel文件的路径吗?



我的XlsxWriter脚本在文件/ app / smth1 / smth2 /中,由于某种原因将excel文件保存到/ app /。不应该将它保存在脚本所在的同一个文件中吗?或者我必须指定这样的路径:

  workbook = xlsxwriter.Workbook('/ app / smth1 / smth2 / Expenses01 .xlsx')

保存excel文件的默认文件是什么?

解决方案

该文件是自己的文件保存到您的本地目录(从中运行文件),例如,我使用的是Python 2.7.6和当我运行这个:

  workbook = xlsxwriter.Workbook('demo.xlsx')

该文件与我的Python文件保存在相同的文件夹中,您还可以指定如下所示的完整路径:

  workbook = xlsxwriter.Workbook('C:/Users/Steven/Documents/demo.xlsx')
/ pre>

这将将我的demo.xlsx文件保存在我的文档文件夹中(假设你在Windows上)
确保所有的路径都正确(大小写敏感,没有损坏),它应该工作,最后一个例子应该是一个警察y和粘贴你是:

  workbook = xlsxwriter.Workbook('app / smth1 / smth2 / Expenses01.xlsx')$注意开始的/不是必需的,可能会导致你的错误(至少在Windows上,我的...)不能肯定在Mac / Linux上)。祝你好运! 
可以找到示例此处


Where does Xlsxwriter save the files you have created? Is it possibly to specify the path where I want the excel files to be saved?

My XlsxWriter script was in file /app/smth1/smth2/ and for some reason it saved the excel file to /app/. Shouldn't it have saved it in the same file where the script was? Or do I have to specify the path like this:

workbook = xlsxwriter.Workbook(' /app/smth1/smth2/Expenses01.xlsx')

What is the default file where the excel file is saved?

解决方案

The file it's self is saved to your local directory (where you run the file from) for example, I am using Python 2.7.6, and when I run this:

workbook = xlsxwriter.Workbook('demo.xlsx')

The file is saved in the same folder as my Python file, you can also specify a full path like so:

workbook = xlsxwriter.Workbook('C:/Users/Steven/Documents/demo.xlsx')

And this will save my demo.xlsx file in my documents folder (assuming you are on windows) Make sure all of your paths are correct (case sensitive, and none corrupted) and it should work, the final example that should be a copy and paste for you is:

workbook = xlsxwriter.Workbook('app/smth1/smth2/Expenses01.xlsx')

Notice the starting "/" is not needed and may be causing your errors (at least on Windows, I can't say for sure on Mac/Linux). Best of luck! Examples can be found here

这篇关于如何在特定的路径保存Xlsxwriter文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆