import ftplib
import urllib2
import os
import logging
logger = logging.getLogger('ftpuploader')
hdlr = logging.FileHandler('ftplog.log')
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logging.INFO)
FTPADDR = "some ftp address"
def upload_to_ftp(con, filepath):
    try:
        f = open(filepath,'rb')                # file to send
        con.storbinary('STOR '+ filepath, f)         # Send the file
        f.close()                                # Close file and FTP
        logger.info('File successfully uploaded to '+ FTPADDR)
    except, e:
        logger.error('Failed to upload to ftp: '+ str(e))ดูเหมือนจะใช้งานไม่ได้ฉันได้รับข้อผิดพลาดทางไวยากรณ์วิธีที่เหมาะสมในการทำเช่นนี้สำหรับการบันทึกข้อยกเว้นทุกประเภทลงในไฟล์คืออะไร
,หลังจากexceptนั้นคุณจะได้รับglobal name 'e' is not definedซึ่งไม่ดีไปกว่าไวยากรณ์ที่ผิด
                except Exception as eหรือexcept Exception, eขึ้นอยู่กับเวอร์ชันของ Python
                
,except