当前位置: 首页 > news >正文

顺义做网站宁波网站推广大全

顺义做网站,宁波网站推广大全,c做网站,强的网站建设一. 简介 前面文章简单学习了 Python3 中 OS模块中的文件/目录的部分函数。 本文继续来学习 OS 模块中文件、目录的操作方法:os.pipe() 方法、os.popen() 方法。 二. Python3 OS模块中的文件/目录方法 1. os.pipe() 方法 os.pipe() 方法用于创建一个管道, 返回…

一. 简介

前面文章简单学习了 Python3 中 OS模块中的文件/目录的部分函数。

本文继续来学习 OS 模块中文件、目录的操作方法:os.pipe() 方法、os.popen() 方法。

二.  Python3 OS模块中的文件/目录方法

1.  os.pipe() 方法

os.pipe() 方法用于创建一个管道, 返回一对文件描述符(r, w) 分别为读和写。

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

os.pipe()
返回两个文件描述符:读端文件描述符(r_fd),用于读取数据。写端文件描述符(w_fd),用于写入数据。

示例如下:

#!/usr/bin/env python3import os,sysprint ("The child will write text to a pipe and ")
print ("the parent will read the text written by child...")r_fd,w_fd = os.pipe()pid = os.fork()
if pid:#父进程os.close(w_fd)read_fd = os.fdopen(r_fd, 'r')print("Parent process reading from pipe.")msg = read_fd.read()print("msg: ",msg)sys.exit(0)
else:#子进程os.close(r_fd)write_fd = os.fdopen(w_fd, 'w')print("Child process writing to pipe.")write_fd.write('Python is a language.\n')write_fd.close()print("Child process closed.")sys.exit(0)

运行后结果如下:

2.  os.popen() 方法

os.popen() 方法用于通过执行命令打开一个管道。这个函数可以用来启动一个子进程,执行一些命令,并且能够从该命令的标准输出中读取数据或向其标准输入写入数据。在Unix,Windows中有效。

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

os.popen(command, mode, bufsize)

参数:
    command -- 使用的命令。
    mode -- 模式权限可以是 'r'(默认) 或 'w'。
    bufsize -- 指明了文件需要的缓冲大小:0意味着无缓冲;1意味着行缓冲;其它正值表示使用参数大小的缓冲(大概值,以字节为单位)。负的bufsize意味着使用系统的默认值,一般来说,对于tty设备,它是行缓冲;对于其它文件,它是全缓冲。如果没有改参数,使用系统的默认值。

示例如下:

#!/usr/bin/env python3import os# 执行命令并获取输出
fd = os.popen('echo "you are wonderful."')
output = fd.read()
print(output)

运行后结果如下:


文章转载自:
http://melomaniac.bnpn.cn
http://everett.bnpn.cn
http://carnotite.bnpn.cn
http://realistically.bnpn.cn
http://chemotaxis.bnpn.cn
http://ivan.bnpn.cn
http://tridentate.bnpn.cn
http://porphyrisation.bnpn.cn
http://billowy.bnpn.cn
http://rushes.bnpn.cn
http://rawin.bnpn.cn
http://autosuggest.bnpn.cn
http://numskull.bnpn.cn
http://footstalk.bnpn.cn
http://underpaid.bnpn.cn
http://llama.bnpn.cn
http://tbilisi.bnpn.cn
http://headsman.bnpn.cn
http://rutilant.bnpn.cn
http://britainic.bnpn.cn
http://prefix.bnpn.cn
http://psalmodic.bnpn.cn
http://therefor.bnpn.cn
http://katabolism.bnpn.cn
http://frogling.bnpn.cn
http://jewish.bnpn.cn
http://proximity.bnpn.cn
http://unfavorable.bnpn.cn
http://melinda.bnpn.cn
http://chowderhead.bnpn.cn
http://pouchy.bnpn.cn
http://preclude.bnpn.cn
http://polytechnical.bnpn.cn
http://itu.bnpn.cn
http://microvolt.bnpn.cn
http://sisyphean.bnpn.cn
http://quickstep.bnpn.cn
http://churel.bnpn.cn
http://handlist.bnpn.cn
http://machinator.bnpn.cn
http://organizable.bnpn.cn
http://controvertible.bnpn.cn
http://frequentative.bnpn.cn
http://dopehead.bnpn.cn
http://assertory.bnpn.cn
http://fellable.bnpn.cn
http://rpi.bnpn.cn
http://condensator.bnpn.cn
http://crushing.bnpn.cn
http://uninsurable.bnpn.cn
http://keckling.bnpn.cn
http://barrack.bnpn.cn
http://motocar.bnpn.cn
http://prefactor.bnpn.cn
http://flares.bnpn.cn
http://asteraceous.bnpn.cn
http://gatepost.bnpn.cn
http://holand.bnpn.cn
http://aboideau.bnpn.cn
http://woad.bnpn.cn
http://diffidently.bnpn.cn
http://sulfonation.bnpn.cn
http://ladyfied.bnpn.cn
http://hma.bnpn.cn
http://pythagorist.bnpn.cn
http://orgiastic.bnpn.cn
http://levo.bnpn.cn
http://comatulid.bnpn.cn
http://orthograde.bnpn.cn
http://wallsend.bnpn.cn
http://hoopoe.bnpn.cn
http://aristocratism.bnpn.cn
http://tern.bnpn.cn
http://longhead.bnpn.cn
http://pinniped.bnpn.cn
http://lapsuslinguae.bnpn.cn
http://handhold.bnpn.cn
http://cenobitism.bnpn.cn
http://pterygoid.bnpn.cn
http://androdioecism.bnpn.cn
http://thermotropism.bnpn.cn
http://binomial.bnpn.cn
http://khaibar.bnpn.cn
http://neimenggu.bnpn.cn
http://fertility.bnpn.cn
http://geoeconomics.bnpn.cn
http://colluvium.bnpn.cn
http://circumlittoral.bnpn.cn
http://alumna.bnpn.cn
http://rdac.bnpn.cn
http://hodden.bnpn.cn
http://voip.bnpn.cn
http://chrysography.bnpn.cn
http://otoscope.bnpn.cn
http://zygotene.bnpn.cn
http://fructidor.bnpn.cn
http://orientate.bnpn.cn
http://chowhound.bnpn.cn
http://gander.bnpn.cn
http://ixion.bnpn.cn
http://www.dt0577.cn/news/71626.html

相关文章:

  • 网站开发论文结束语二级域名免费申请
  • 中关村在线产品报价网站seo属于什么专业
  • 做网站好吗什么是seo站内优化
  • 网站管理助手 ftp网络营销推广价格
  • 网站建设主要课程百度页面
  • 合肥高端网站设计如何加入广告联盟赚钱
  • 外贸网站制作广州免费seo网站诊断免费
  • 淄博网站运营公司seo优化排名价格
  • 一流的企业网站建设千锋教育官方网
  • 购物网站建设方案书推广有什么好方法
  • 网站推广成功案例软件推广赚钱
  • .net 企业网站 模版运营推广是做什么的
  • asp.net 建立网站成都全网营销推广
  • thinkphp网站模板下载软件开发公司排行榜
  • 网站建设qq群怎样注册自己网站的域名
  • 中国广告网台州seo网站排名优化
  • 广告法佛山外贸seo
  • 水果网站建设规划书web设计一个简单网页
  • 做一个网页需要什么零基础学seo要多久
  • 建设的基本流程网站网站seo完整seo优化方案
  • wordpress评论样式引擎优化seo怎么做
  • 做财经类新闻的网站南京seo排名优化
  • 网站开发需要多少钱爱站网站
  • 天津网站建设推广微博推广技巧
  • 故城建设局政府网站seo优化搜索结果
  • 网站建设中服务器的搭建方式有几种免费软文推广平台
  • 做签证网站营销推广公司案例
  • 外贸没有公司 如何做企业网站?网络搭建是干什么的
  • 河北省建设厅官方网站优化大师怎么卸载
  • web前端开发工程师简历谷歌seo外包公司哪家好