开发者

Using getcwd when running in Eclipse

When running a project in eclipse the eclipse saves a copy of the .py file inside the workspace defined in project creation. But the file that imported to project can be in other location.

If using os.getcwd() and running the script from the command line, the return value would be the real path of the script file, but when running the script from inside eclipse, the return value would be the path of the workspace, where eclipse saves a copy of the original file.

So the ques开发者_开发技巧tion is, since I run my script during debugging from eclipse, how can I verify that it works before moving to real environment? Is there other way other than getcwd()?

Thanks, Isaac


os.getcwd() returns the current working directory.

When running a Python program from Eclipse you can specify what the working directory should be on the Arguments tab of the Run Configuration. This will let you override the value from the project folder (or whatever the default might be.)

Using getcwd when running in Eclipse

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜