Python writes hadoop program to report error stop iteration? under ubuntu

problem description

the platform version of the problem and what methods you have tried

Watch hadoop videos on

imooc,
ubuntu18.04 systems, and use anaconda3"s python interpreter to execute.
my code is exactly the same as in the video.

related codes

/ / Please paste the code text below (do not replace the code with pictures)
def read_lines (hdfs_client):

file_b = "/tmp/test/file_b"
with hdfs_client.open(file_b, "wb", replication=1 ) as f:
    f.write(b"hello\nhadoop")
    
with hdfs_client.open(file_b, "rb") as f:
    lines = f.readlines()
    assert len(lines) = 2

what result do you expect? What is the error message actually seen?

although there is a problem running, but looking at the file_b file, two lines of hello hadoop (have been written)
so what"s wrong with that f.readlines?

the video is executed with python2, which I haven"t tried.
under my anaconda, I can"t run without the python2 module that comes with the python3, system.

Dec.01,2021

assert len (lines) = 2 should be assert len (lines) = = 2

Menu