I need to make sure that a user-provided string is permissible as a filename on my system. To do this, I need to replace any forbidden characters with ‘_’. The list of forbidden characters varies by OS, so I am wondering if there is already a function available that takes this into account.
Using str.replace()
is an option, but I am looking for something that is already available.