2011-08-25 96 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屬性 - 即它用於什麼。