This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: bug: string search can find \n, but can NEVER find \r
Type: behavior Stage: resolved
Components: Versions: Python 3.9
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: methane, xuancong84
Priority: normal Keywords:

Created on 2019-10-17 08:22 by xuancong84, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg354834 - (view) Author: wang xuancong (xuancong84) Date: 2019-10-17 08:22
If I load a file which contains "\r" and "\n", I can find "\n", but not "\r". This behaviour is inconsistent in Python 3, but consistent in Python 2.

>>> open('./3cjkxdnw/accessibilityLog/1570181896323.csv', 'rb').read().count(b'\r')
88
>>> open('./3cjkxdnw/accessibilityLog/1570181896323.csv').read().count('\r')
0
>>> type(open('./3cjkxdnw/accessibilityLog/1570181896323.csv').read())
<class 'str'>
>>> type('\r')
<class 'str'>

Thanks!
msg354835 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2019-10-17 08:29
It is "universal newline".
See
https://docs.python.org/3/library/functions.html#open
and
https://docs.python.org/3/glossary.html#term-universal-newlines
History
Date User Action Args
2022-04-11 14:59:21adminsetgithub: 82684
2019-10-17 08:29:47methanesetstatus: open -> closed

nosy: + methane
messages: + msg354835

resolution: not a bug
stage: resolved
2019-10-17 08:22:02xuancong84create