Search code examples
pythonglob

Python glob path issue


I have a question about using glob in python.

I want to know why the path is showing backslashes instead of a forward slash?

Example being C:/Users/Name/Desktop/Pythonfiles\excel.xlsx

My script is

import glob
excel_list = (glob.glob("C:/Users/Name/Desktop/Pythonfiles/*.xlsx"))

This is my output I'm getting:

['C:/Users/Name/Desktop/PythonFiles\\19282.xlsx', 'C:/Users/Name/Desktop/PythonFiles\\19557.xlsx', 'C:/Users/Name/Desktop/PythonFiles\\19667.xlsx', 'C:/Users/Name/Desktop/PythonFiles\\19742.xlsx', 'C:/Users/Name/Desktop/PythonFiles\\CEImport.xlsx']

Any help would be great thank you


Solution

  • According to this answer here, '/' and '\' are interchangeable in python file paths.