Cross-platform:
import os
import sys
f = open(os.devnull, 'w')
sys.stdout = f
On Windows:
f = open('nul', 'w')
sys.stdout = f
On Linux:
f = open('/dev/null', 'w')
sys.stdout = f
More Related Contents:
- Remove string in python dictionary value
- Searching for IP addresses in a file
- Swapping variable places inside if throws an error
- Export a list of stock prices to excel
- python program doesn’t work
- Text parsing and retrieval
- Check if the element is last in the list
- What’s wrong with my Python 2 program?
- How do you send a HEAD HTTP request in Python 2?
- Skip the headers when editing a csv file using Python
- Removing unicode \u2026 like characters in a string in python2.7 [duplicate]
- Getting only element from a single-element list in Python?
- ImportError: cannot import name NUMPY_MKL
- Print Combining Strings and Numbers
- Python Pip install Error: Unable to find vcvarsall.bat. Tried all solutions [duplicate]
- How do i use subprocesses to force python to release memory?
- How do I make a fixed size formatted string in python? [duplicate]
- Chromedriver, Selenium – Automate downloads
- Python: import module from another directory at the same level in project hierarchy
- Python docx Replace string in paragraph while keeping style
- Get a unique list of items that occur more than once in a list
- Can’t create pdf using python PDFKIT Error : ” No wkhtmltopdf executable found:”
- Python: setting two variable values separated by a comma in python
- Switch between python 2.7 and python 3.5 on Mac OS X
- How to modify the default font in Tkinter?
- creating a spiral array in python?
- Python returns length of 2 for single Unicode character string
- Run process with realtime output to a Tkinter GUI
- Any way to get one process to have a write lock and others to just read on parallel?
- Google Search Web Scraping with Python