在mac上导入pyPDF2错误

时间:2017-05-23 06:02:50

标签: python macos

通过终端安装pyPDF2包 pip安装pyPDF2 - 没有错误

import pyPDF2
import docx
import string

pdf = pyPdf.PdfFileReader(file("Accmanager.pdf", "rb"))
# Iterate pages
for i in range(0, pdf.getNumPages()):
    # Extract text from page and add to content
content += pdf.getPage(i).extractText() + "\n"
# Collapse whitespace
content = " ".join(content.replace(u"\xa0", " ").strip().split())

1 个答案:

答案 0 :(得分:0)

拼写首字母'p'的小修正应该是大写,试试这个:

$dataSet      = [];
$error_dispay = [];
$product_fob  = 0;
$invoice_fob  = 0;
foreach ($post_data as $postdata) {
    foreach ($invoice_data as $invoicedata) {
        $invoice_fob += floatval($invoicedata->invoice_value);
        if (trim($invoicedata->invoice_no) == trim($postdata[0])) {
            $product_fob += floatval($postdata[6]) * floatval($postdata[4]);
            $dataSet[] = [
                'session_token'       => $session_token,
                'invoice_no'          => $postdata[0],
                'ritc'                => $postdata[2],
                'product_description' => $postdata[3],
                'unit_price'          => $postdata[4],
                'quantity'            => $postdata[6],
                'amount'              => floatval($postdata[6]) * floatval($postdata[4]),
                'fob'                 => floatval($postdata[6]) * floatval($postdata[4]),
                'pmv_value'           => $postdata[7],
            ];
        } else {
            $error_dispay['error'] = $invoicedata->invoice_no;
        }

    }
}