python 2到3迁移错误“readinto”方法

2024-06-17 11:38:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我转换了一个在python2.7.3中编写的大文件,然后我想升级到python3+(我有3.5)。在

  1. 到目前为止我所做的:
    1. 安装了python解释器3.5+
    2. 更新了从python3+文件夹读取的环境路径
    3. 升级了numpy,熊猫
    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')

我的错误是:

^{pr2}$

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


Tags: 文件pyimport路径numpy文件夹环境as