Check if file is a named pipe (fifo) in python?

2019-01-25 05:04发布

问题:

I communicate with a named pipe, but I would like to check if it really is a named pipe BEFORE opening it.

I check in Google but there is nothing, os.path.isfile() returns False, and I really need to check it.

回答1:

You can try:

 import stat, os

 stat.S_ISFIFO(os.stat(path).st_mode)

docs



标签: python pipe