jumpserver-python-sdk icon indicating copy to clipboard operation
jumpserver-python-sdk copied to clipboard

正则匹配的一个细节问题

Open wufeiqun opened this issue 7 years ago • 0 comments

https://github.com/jumpserver/jumpserver-python-sdk/blob/d58cb3170fbe0f0410b752a1241318513aa0ccea/jms/utils.py#L177

前面不应该加r, 参考:

The solution is to use Python’s raw string notation for regular expression patterns; backslashes are not handled in any special way in a string literal prefixed with 'r'. So r"\n" is a two-character string containing '' and 'n', while "\n" is a one-character string containing a newline. Usually patterns will be expressed in Python code using this raw string notation.

https://docs.python.org/3.6/library/re.html

wufeiqun avatar Sep 13 '17 05:09 wufeiqun