Paraview's Python shell not reading file path corectly

余生颓废 提交于 2020-01-25 06:57:10

问题


my main file uses several other files to complete a 3D render in Paraview. I have been using Pythons os library to get the file path that I need. For some reason Paraview breaks when I try to retrieve my path. I am using Paraview's build in shell to run my script.

My code goes as follows:

import os
dir = os.path.dirname(os.path.realpath(__file__))
print(dir)

This line of code works inconsistently and I want to understand why this isn't working

If my file is in a directory named C:\Test\Test1\Test2\Test3\File.py the program works and my output of the print statement is the string 'C:\Test\Test1\Test2\Test3\File.py' . However if I rename one of the directories as follows C:\Test\Test1\run\Test3\File.py it does not work and the output is:

C:\Test\Test1
un\Test3\File.py

Somehow the run directory is getting interpreted as a carriage return \r. Am I getting my file path incorrectly?

Thank you.

来源:https://stackoverflow.com/questions/59752104/paraviews-python-shell-not-reading-file-path-corectly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!