5

我转换了一个巨大的文件,我在 python 2.7.3 中编写了它,然后现在我想升级到 python 3+(我有 3.5)。

  1. 到目前为止我做了什么:
    1. 安装了python解释器3.5+
    2. 更新了从 python3+ 文件夹读取的环境路径
    3. 升级了 numpy、pandas、
    4. 我曾经>python 2to3.py -w viterbi.py转换到版本 3+

我有错误的部分

import sys
import numpy as np
import pandas as pd

# Counting number of lines in the text file
lines = 0
buffer = bytearray(2048)
with open(inputFilePatheName) as f:
    while f.readinto(buffer) > 0:
        lines += buffer.count('\n')

我的错误是:

AttributeError: '_io.TextIOWrapper' object has no attribute 'readinto'

这是第一个错误,我无法继续查看是否还有其他错误。我不知道等效的命令是什么readinto

4

0 回答 0