Create txt file with / in name

1247 views linux
-3

I have a task where I have to generate txt files on my Linux machine with some of their names having '/' in it. Is it possible to do the same in Python3?

eg. "Sheffield Doc/Fest.txt", "True/False Film Fest.txt"

I tried

f = open('Sheffield Doc\\\/Fest.txt', 'w')

but it raises an error.

answered question

What operating system are you using? Windows?

Linux, Ubuntu @AndyLester

You can't have a / in a filename on pretty much any filesystem.

1 Answer

4

If you're using Linux, then you cannot create a filename with a slash in the name, because a slash is the directory separator. That's just a limitation of the operating system. This is not a Python issue.

posted this

Have an answer?

JD

Please login first before posting an answer.