Friday, December 2, 2011

Escape characters python

The one place everybody who starts scripting gets stuck is escape characters . this is about the point where you will have to give either a absolute or relative path from where you will have to open a file , exe etc.

one aspect which i was particularly glad about in python is , python has a inbuilt function to do this (kewl right! )

re.escape(string)

Example : print re.escape("www.example.com")

www\\.example\\.com is your ouput

No comments:

Post a Comment