0

I have the above error in the line row_output = ... How can I fix it?

for index, row_content in enumerate(info):
row_output = 'C:\Users\khana\Documents\all\' + index
if not os.path.exists(row_output):
    os.makedirs(row_output)
Adam
  • 3
  • 2

1 Answers1

0

Cuz the "\" is escape character in python, but in window, it also is the split of path. So we can use "\\" to different them. However, if your OS is mac or liunx, you should use "/". The "/" also is useful for window. So i think the "/" is best choice.

for index, row_content in enumerate(info):
    row_output = 'C:/Users/khana/Documents/all/' + index
    if not os.path.exists(row_output):
        os.makedirs(row_output)
han
  • 146
  • 7
  • yes, thank you. Interesting since it didn't give that error in other cases but thank you – Adam Jun 10 '20 at 02:08
  • Hope it could help u – han Jun 10 '20 at 02:28
  • @Adam, if it did solve your problem, please be sure to mark it as the accepted answer. That will mark this question as resolved, validate that the answer is useful, and start building pntehan’s reputation here on Stack Overflow. – Jeremy Caney Jun 12 '20 at 07:29