sparkydogX / sparkydogx_blog_comment

Comments for https://sparkydogx.github.io
1 stars 0 forks source link

Python中将标准输出重定向到NULL | SparkydogX Blog #130

Open sparkydogX opened 4 years ago

sparkydogX commented 4 years ago

https://sparkydogx.github.io/2019/08/15/python-supress-std-output/#more

123456789101112131415161718192021222324252627import osprint("will run")# open 2 fdsnull_fds = [os.open(os.devnull, os.O_RDWR) for x in range(2)]# save the current file descriptors to a tuplesave = os.