Python 3.6:无法用阿拉伯语保存CSV文件

时间:2017-09-05 16:32:06

标签: python csv tweepy

我正在尝试将我的tweepy结果写成阿拉伯语的CSV文件,但输出文件总是以unicode为例:

<!--Contact Starts-->
        <div class="container contactform center">
            <h2 class="text-center  wowload fadeInUp"></h2>
            <div class="row wowload fadeInLeftBig">      
                  <div class="col-sm-6 col-sm-offset-3 col-xs-12">
                  <form method="post" action="index.php">
                    <input type="text" placeholder="Nombre" name="nombre" required>
                    <input type="email" placeholder="Email" name="email" required>
                    <input type="text" placeholder="Móvil" name="movil" required>
                    <textarea rows="5" placeholder="Mensaje" name="mensaje" required></textarea>
                    <button class="btn btn-danger" type="submit" name="sendBtn"><i class="fa fa-paper-plane"></i> Send</button>
                  </form>
                  </div>
            </div>
        </div>
    </div>
    <!--Contact Ends-->

<?php

if(isset($_POST["sendBtn"])){
    require "PHPMailer/src/PHPMailer.php";
    require "PHPMailer/src/OAuth.php";
    require "PHPMailer/src/SMTP.php";
    require "PHPMailer/src/POP3.php";
    require "PHPMailer/src/Exception.php";

    //Create a new PHPMailer instance

    $mail = new PHPMailer();

    //Tell PHPMailer to use SMTP

    $mail->isSMTP();


    //Enable SMTP debugging

    // 0 = off (for production use)

    // 1 = client messages

    // 2 = client and server messages

    $mail->SMTPDebug = 2;



    //Set the hostname of the mail server

    $mail->Host = 'smtp.gmail.com';

    // use

    // $mail->Host = gethostbyname('smtp.gmail.com');

    // if your network does not support SMTP over IPv6

    //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission

    $mail->Port = 587;

    //Set the encryption system to use - ssl (deprecated) or tls

    $mail->SMTPSecure = 'tls';

    //Whether to use SMTP authentication

    $mail->SMTPAuth = true;

    //Username to use for SMTP authentication - use full email address for gmail

    $mail->Username = "xxx@gmail.com";

    //Password to use for SMTP authentication

    $mail->Password = "xxxxxx";

    //Set who the message is to be sent from

    $mail->setFrom($_POST["email"], $_POST["nombre"]);

    //Set who the message is to be sent to

    $mail->addAddress('xxx@gmail.com', 'John Doe');

    //Set the subject line

    $mail->Subject = 'PHPMailer GMail SMTP test';

    //Read an HTML message body from an external file, convert referenced images to embedded,

    //convert HTML into a basic plain-text alternative body

    $mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));



    //Replace the plain text body with one created manually

    $mail->AltBody = $_POST["mensaje"] . '<br><p Móvil: '.$_POST["movil"].'</p>';


    //send the message, check for errors

    if (!$mail->send()) {

        echo "Mailer Error: " . $mail->ErrorInfo;

    } else {

        echo "Message sent!";

    }
}

我的代码:

u0646 \u060c \u0627\u0644\u0645\u0646\u062a\u062e\u0628 \u0627\u0644\u0633\u0648\u0631\u064a \u0628\u064a\u0631\u062c\u0639 \u0639\u0628\u064a\u062a\u0648 \u0648\u0645\u0627 \u0628\u0634\u0645 \u0627\u0644\u0645\u0644\u062d\u0642 \u062d\u062a\u0649

0 个答案:

没有答案