How to write spaces and symbols in string formatting


string formatting error

Tried all kinds of string formatting no results found

msg.body = '''Dear admin, 

         You requested that your password be reset.
         Please visit the link below or copy and paste it into your browser to create a new password.%s''' \
                   %url_for('.get_resetpassword',token=token,_external=True)%'''

        Thank you,
         Team
        '''

builtins.TypeError TypeError: not all arguments converted during string formatting


Answer

You should use string format later:

msg.body = '''Dear admin, 

         You requested that your password be reset.
         Please visit the link below or copy and paste it into your browser to create a new password.%s  

        Thank you,
         Team
        '''%url_for('.get_resetpassword',token=token,_external=True)

So you don't need to bother with anything.

Or use:

msg.body = '''Dear admin, 

         You requested that your password be reset.
         Please visit the link below or copy and paste it into your browser to create a new password.%s''' \
                   %url_for('.get_resetpassword',token=token,_external=True)+'''

        Thank you,
         Team
        '''