'How to correctly read file paths from a directory in python?

I have the following function to read files from a directory.

def collect_doc(root, verboose = True):
    filepaths = [os.path.join(root, i) for i in os.listdir(root)]
    if verboose: 
        print(f"filepaths={filepaths}")
    return filepaths

It works but I get the following:

filepaths=['C:/Users/Admin/Downloads/corpus\\0.txt', 'C:/Users/Admin/Downloads/corpus\\1.txt']

I am looking to get the same but as following:

 filepaths=['C:/Users/Admin/Downloads/corpus/0.txt', 'C:/Users/Admin/Downloads/corpus/1.txt']


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source