import obspy报错‘numpy.int64‘ object has no attribute ‘split‘`

本文介绍了解决在使用numpy int64类型时遇到的AttributeError错误,具体错误为尝试调用不存在的'split'属性。通过将numpy int64类型的变量转换为字符串类型,成功解决了此问题。
摘要由CSDN通过智能技术生成

line = line.split(comment, 1)[0] AttributeError: ‘numpy.int64’ object has no attribute ‘split’

import obspy时报错
line = line.split(comment, 1)[0] AttributeError: 'numpy.int64' object has no attribute 'split'

File "/Users/jiangyue/miniforge3/envs/python38/lib/python3.8/site-packages/numpy/lib/npyio.py", line 977, in split_line line = line.split(comment, 1)[0]
打开这个npyio.py文件,找到报错的这一行

    def split_line(line: str):
        """Chop off comments, strip, and split at delimiter."""
        for comment in comments:  # Much faster than using a single regex.
            line = line.split(comment, 1)[0]
        line = line.strip('\r\n')
        return line.split(delimiter) if line else []

把line转换为str类型:

    def split_line(line: str):
        """Chop off comments, strip, and split at delimiter."""
        for comment in comments:  # Much faster than using a single regex.
            line = str(line).split(comment, 1)[0]
        line = line.strip('\r\n')
        return line.split(delimiter) if line else []
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值