diff --git a/numpy/random/_generator.pyx b/numpy/random/_generator.pyx index cd0b248723d2..e2430d139a42 100644 --- a/numpy/random/_generator.pyx +++ b/numpy/random/_generator.pyx @@ -585,7 +585,7 @@ cdef class Generator: Examples -------- >>> np.random.default_rng().bytes(10) - b'\xfeC\x9b\x86\x17\xf2\xa1\xafcp' # random + b'\\xfeC\\x9b\\x86\\x17\\xf2\\xa1\\xafcp' # random """ cdef Py_ssize_t n_uint32 = ((length - 1) // 4 + 1) diff --git a/numpy/random/mtrand.pyx b/numpy/random/mtrand.pyx index 863879a0465f..4f5862faa1d9 100644 --- a/numpy/random/mtrand.pyx +++ b/numpy/random/mtrand.pyx @@ -795,7 +795,7 @@ cdef class RandomState: Examples -------- >>> np.random.bytes(10) - ' eh\\x85\\x022SZ\\xbf\\xa4' #random + b' eh\\x85\\x022SZ\\xbf\\xa4' #random """ cdef Py_ssize_t n_uint32 = ((length - 1) // 4 + 1) # Interpret the uint32s as little-endian to convert them to bytes