python - pandas html 函数转换为浮点数
问题描述
我有一个 df,我正在将其转换为 HTML 以作为电子邮件附件发送。
电子邮件功能:-
def send_email(text,html,me,you):
#me = "test@gmail.com"
#you = "test@test.com"
# Create message container - the correct MIME type is multipart/alternative.
msg = MIMEMultipart('alternative')
msg['Subject'] = "Link"
msg['From'] = me
msg['To'] = you
# Record the MIME types of both parts - text/plain and text/html.
part1 = MIMEText(text, 'plain')
part2 = MIMEText(html, 'html')
# Attach parts into message container.
# According to RFC 2046, the last part of a multipart message, in this case
# the HTML message, is best and preferred.
msg.attach(part1)
msg.attach(part2)
# Send the message via local SMTP server.
s = smtplib.SMTP('localhost')
# sendmail function takes 3 arguments: sender's address, recipient's address
# and message to send - here it is sent as one string.
s.sendmail(me, you, msg.as_string())
之后,我将我的 DF 转换为 HTML:-
text = "below is the data"
html = df.to_html()
它将所有数字字段转换为浮点数。我怎样才能避免这种情况?
解决方案
推荐阅读
- visual-studio-code - VSCode Python 语言服务器不再显示
- reactjs - 如何为 map 函数中的解构对象数组定义接口?
- git - git的问题:远程源已经存在
- shopify - Shopify 更新自定义捆绑包的库存
- asp.net - 在后台处理请求
- php - Laravel excel:Excel::create 等价物
- html - AMP Iframe CSS 媒体查询
- r - 如何正确使用 scale_x_date
- javascript - 是否可以在 jQuery 中将多个 HTML 元素合并到一个脚本中?
- php - Yii2 JUI datepicker 从输入字段中删除 HTML 属性