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.)
精彩评论