问题
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