Python os.openpty() 方法

Python 教程 · 2019-02-04 08:27:45

概述

os.openpty() 方法用于打开一个新的伪终端对。返回 pty 和 tty的文件描述符。

语法

openpty()方法语法格式如下:

os.openpty()

参数

返回值

返回文件描述符对,主从。

实例

以下实例演示了 openpty() 方法的使用:

#!/usr/bin/python
# -*- coding: UTF-8 -*-

import os

# 主 pty, 从 tty
m,s = os.openpty()

print m
print s

# 显示终端名
s = os.ttyname(s)
print m
print s

执行以上程序输出结果为:

3
4
3
/dev/pty0

点击查看所有 Python 教程 文章: https://www.codercto.com/courses/l/8.html

查看所有标签

Distributed Algorithms: An Intuitive Approach

Distributed Algorithms: An Intuitive Approach

Wan Fokkink / MIT Press / 2018-2-2 / USD 48.00

The new edition of a guide to distributed algorithms that emphasizes examples and exercises rather than the intricacies of mathematical models. This book offers students and researchers a guide to ......一起来看看 《Distributed Algorithms: An Intuitive Approach》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具