خرید بک لینک

Vote count: 0

#! python3
from contextlib import redirect_stderr
import io

f = io.StringIO()
with redirect_stderr(f):
    # simulates an error
    erd

As seen above, I have used the redirect_stderr function to redirect stderr to a StringIO object. However, it doesn't work, as the error message is still printed out in command prompt:

Traceback (most recent call last):
  File "C:Usersmaxtesterr.py", line 8, in <module>
    erd
NameError: name 'erd' is not defined

I tested it on Python 3.5.1 64 bit and 3.5.2 64 bit with the same results.

A similar issue in this thread

I have also tried writing the error to a file as described in the linked thread, but the file is empty after ruing the script.

asked 29 secs ago

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 20 تير 1395 ساعت: 19:28

صفحه بندی