I tried imitating my code in simple steps on python prompt:
>>> path="D:/workspace/a/b\\c\\d.txt"
>>> path[0,18]
But it gives me following error:
TypeError: string indices must be integers
I wanted to retrieve only directory as path. That is, I want to strip away the file name: D:/workspace/a/b\\c
Why I am getting this error?
path[0:18]notpath[0,18]. The:is your problempath[0,18]is parsed by Python as "look up index(0, 18)in the path", and you can't index a string by a tuplearr = np.array([[1,2,3,4,5],[6,7,8,9,1]])thenprint (arr[0,4])will result in4. This is just to show that[0,4]is not wrong and works on 2d arrays but not on the string you provided.