本文整理匯總了Python中os.O_TEXT屬性的典型用法代碼示例。如果您正苦於以下問題:Python os.O_TEXT屬性的具體用法?Python os.O_TEXT怎麽用?Python os.O_TEXT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類os
的用法示例。
在下文中一共展示了os.O_TEXT屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: wtrf
# 需要導入模塊: import os [as 別名]
# 或者: from os import O_TEXT [as 別名]
def wtrf():
if sys.platform != "win32":
wt = int(os.environ['MYHDL_TO_PIPE'])
rf = int(os.environ['MYHDL_FROM_PIPE'])
else:
wt = msvcrt.open_osfhandle(int(os.environ['MYHDL_TO_PIPE']), os.O_APPEND | os.O_TEXT)
rf = msvcrt.open_osfhandle(int(os.environ['MYHDL_FROM_PIPE']), os.O_RDONLY | os.O_TEXT)
return wt, rf
示例2: create_file_from_handle
# 需要導入模塊: import os [as 別名]
# 或者: from os import O_TEXT [as 別名]
def create_file_from_handle(handle, mode="r"):
"""Return a Python :class:`file` arround a windows HANDLE"""
fd = msvcrt.open_osfhandle(handle, os.O_TEXT)
return os.fdopen(fd, mode, 0)
示例3: open_handle
# 需要導入模塊: import os [as 別名]
# 或者: from os import O_TEXT [as 別名]
def open_handle(handle, mode):
flags = 0
if 'w' not in mode and '+' not in mode:
flags |= os.O_RDONLY
if 'b' not in mode:
flags |= os.O_TEXT
if 'a' in mode:
flags |= os.O_APPEND
return msvcrt.open_osfhandle(handle, flags)
示例4: create_file_from_handle
# 需要導入模塊: import os [as 別名]
# 或者: from os import O_TEXT [as 別名]
def create_file_from_handle(handle, mode="r"):
"""Return a Python :class:`file` around a ``Windows`` HANDLE"""
flags = os.O_BINARY if "b" in mode else os.O_TEXT
fd = msvcrt.open_osfhandle(handle, flags)
kwargs = {}
if windows.pycompat.is_py3 and flags == os.O_TEXT:
# Buffering, encoding
args = (100, "ascii")
else:
# Buffering
args = (0,)
# In py2 os.fdopen do not accept kwargs
return os.fdopen(fd, mode, *args)