【发布时间】:2017-08-09 14:36:17
【问题描述】:
我的输出来了:临时表中的总记录是 (3L,) 我只想要 n 号括号,我怎样才能删除 L , 我将查询转换为 str 因为我无法连接 part1 和 msg
#!/usr/bin/env python
import csv
import MySQLdb
import pysftp
import smtplib
import sys
#connection to Database
conn = MySQLdb.connect(host="XXXXX", # The Host
user="XXXXX", # username
passwd="XXXXX", # password
db="XXXXX") # name of the data base
part1 = """From: XXXXX
To: To Person <XXXXX.com>
MIME-Version: 1.0
Content-type: text/html
Subject: SMTP HTML e-mail test
Toatal records in Staging Table inserted:
"""
sender = 'XXXXX'
receivers = ['XXXXX','XXXXX']
x = conn.cursor()
query = "select count(*) as toatal_records_inserted from fpwbs_feed_stg"
x.execute(query)
msg = ""
for row in x.fetchall():
msg += str(row)
msg=part1+msg
smtpObj=smtplib.SMTP('XXXXX', 25)
smtpObj.sendmail(sender, receivers, msg)
【问题讨论】: