Skip to content

输入与输出章节:TypeError: a bytes-like object is required, not 'str' #22

Description

@BeyondYourself

在章节https://github.com/teadocs/numpy-cn/blob/master/docs/user/basics/io.md中,运行一下代码data = "1, 2, 3, 4, 5, 6" np.genfromtxt(BytesIO(data), delimiter=",")出现TypeError: a bytes-like object is required, not 'str'错误
我得环境是python3.7.
此处的代码应该改为np.genfromtxt(BytesIO(data.encode()), delimiter=",")就可以正常运行

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions