在Python

时间:2016-09-21 16:13:18

标签: python

我是Python的新手,我不确定数据类型。如果我编码  wordfile = open("Sentence.txt","w")。什么数据类型" wordfile"是

1 个答案:

答案 0 :(得分:2)

它是activePlayer,即IO操作的处理程序。

Text IO Wrapper

>>> wordfile = open('file.txt', 'w') >>> wordfile <_io.TextIOWrapper name='file.txt' mode='w' encoding='cp1255'> >>> type(wordfile) <class '_io.TextIOWrapper'> 此类包含在open模块中,但无需导入io即可访问。但是,您可以导入io模块并直接使用io方法。

正如官方文件所声称:

  

类io.TextIOWrapper

     

io.open上的缓冲文字流   二进制流。

表示BufferedIOBase使用TextIOWrapper 二进制流作为一个&#39;频道&#39;对于文本流,它可以处理文本文件。

  

class io.BufferedIOBase

     

支持某种缓冲的二进制流的基类。