2011-08-25 19 views
0

我有两件事要问在这里..请帮助我,因为我是新的python。python os模块popen和tmpfile函数

第一 我无法弄清楚蟒蛇os.popen功能的使用方法...我知道的是,它是用来开的子进程......我试图做的same..tried打开命令提示符在Windows 7上。该文档给出语法为popen(命令,[模式,[bufsize]]),并说“打开一个管道到或从命令。返回值是一个打开的文件对象连接到管道...”我不明白什么打开一个管道的命令意味着什么或管道意味着什么。

,如果你还可以亲切地解释一下什么是popen2,popen3和popen4的目的....

第二

我试图用这个功能os.tmpfile

>>> tmpf=os.tmpfile() 
>>> type(tmpf) 
<type 'file'> 
>>> dir(tmpf) 
['__class__', '__delattr__', '__doc__', '__enter__', '__exit__', '__format__', '__getattribute__', '__hash__', '__init__', '__iter__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'close', 'closed', 'encoding', 'errors', 'fileno', 'flush', 'isatty', 'mode', 'name', 'newlines', 'next', 'read', 'readinto', 'readline', 'readlines', 'seek', 'softspace', 'tell', 'truncate', 'write', 'writelines', 'xreadlines'] 

因为它说tmpf有一个类型文件

我试过以下

帮助(file.softspace)

--and--

帮助(tmpf.softspace)

,但让我吃惊既有助于命令的输出是一大堆不同....

可能会请你,为什么这种行为解释..

翘首等待您的帮助..提前:)

+0

你有没有考虑阅读python文档? – ThiefMaster

+0

我读过文档UT,它对我来说不是很清楚。 KINDLY PARDON,因为我仍然活跃于PYTHON。如果你能帮助,会很有帮助。 – PyBegginer

+0

至少我不会帮助任何人喊(盖帽)。希望其他人也这样做,... – ThiefMaster

回答

0

help(tmpf.softspace)显示的的值的帮助

thankx- 这是int

help(file.softspace)但是显示帮助softspace属性 - 即它用于什么。