On 07/28/2010 03:41 PM, Rod wrote:
Hello,
I need to replace a period (.) in a domain name with a slash period (\.).
I'm attempting to use the string replace method to do this.
Example:
uri = domain.com
uri.replace('.', '\.')
This returns 'domain\\.com'
Of course it does! Try to print
> Try
print uri.replace('.', '\.')
> and you'll find the replacement works fine.
>
> Or write the output to file, and look at the file.
>
> Python shows a representation on its prompt, and thus needs to escape the
> backslash (by prepending another backslash). Otherwise you might think '\.'
Hello,
I need to replace a period (.) in a domain name with a slash period (\.).
I'm attempting to use the string replace method to do this.
Example:
uri = domain.com
uri.replace('.', '\.')
This returns 'domain\\.com'
Is there a way to do this so there is not a double slash before the period