(s)
return re.sub(r"(?u)[^-\w.]", "", s)
Return the given string converted to a string that can be used for a clean
    filename. Remove leading and trailing spaces; convert other spaces to
    underscores; and remove anything that is not an alphanumeric, dash,
    underscore, or dot.
    >>> get_valid_filename("john's portrait in 2004.jpg")
    'johns_portrait_in_2004.jpg'

    Source: https://github.com/django/django/blob/master/django/utils/text.py
Return the given string converted to a string that can be used for a clean
    filename. Remove leading and trailing spaces; convert other spaces to
    underscores; and remove anything that is not an alphanumeric, dash,
    underscore, or dot.
    >>> get_valid_filename("john's portrait in 2004.jpg")
    'johns_portrait_in_2004.jpg'
Return the given string converted to a string that can be used for a clean filename . Remove leading and trailing spaces ; convert other spaces to underscores ; and remove anything that is not an alphanumeric dash underscore or dot . >>> get_valid_filename ( john s portrait in 2004 . jpg ) johns_portrait_in_2004 . jpg
def get_valid_filename(s):
    """
    Return the given string converted to a string that can be used for a clean
    filename. Remove leading and trailing spaces; convert other spaces to
    underscores; and remove anything that is not an alphanumeric, dash,
    underscore, or dot.
    >>> get_valid_filename("john's portrait in 2004.jpg")
    'johns_portrait_in_2004.jpg'

    Source: https://github.com/django/django/blob/master/django/utils/text.py
    """
    s = str(s).strip().replace(" ", "_")
    return re.sub(r"(?u)[^-\w.]", "", s)
def get_valid_filename ( s ) : s = str ( s ) . strip ( ) . replace ( " " , "_" ) return re . sub ( r"(?u)[^-\w.]" , "" , s )