Python: prevent replacing% s with string

Is there a way to mark the line in such a way that it doesn't cause python% line replacement?

Specifically, I am trying to load a file whose name includes% using the python module sftp

. The sftp module tries to write the filename using the registration module:

self.logger.log(level, msg, *args)


and logging

complain about string formatting due to% signs:

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/", line 328, in getMessage
    msg = msg % self.args
TypeError: not enough arguments for format string


So: since I have no control over the filename or the sftp module, can I mark the filename as not participating in the string replacement?


source to share

1 answer

mystring.replace('%', '%%')

can meet your needs. %%

goes beyond %




All Articles