相关疑难解决方法(0)

Python中iter函数的第二个参数是什么?

我们考虑一个文件:

$ echo -e """This is a foo bar sentence .\nAnd this is the first txtfile in the corpus .""" > test.txt
$ cat test.txt 
This is a foo bar sentence .
And this is the first txtfile in the corpus .
Run Code Online (Sandbox Code Playgroud)

当我想逐个阅读文件时,我可以做/sf/answers/1755011331/:

>>> fin = open('test.txt')
>>> while fin.read(1):
...     fin.seek(-1,1)
...     print fin.read(1),
... 
T h i s   i s   a   f o o   b a r   s e n t e n c e   . …
Run Code Online (Sandbox Code Playgroud)

python arguments iterable built-in

1
推荐指数
1
解决办法
1027
查看次数

标签 统计

arguments ×1

built-in ×1

iterable ×1

python ×1