python - HTML 文件中的 Python 变量
问题描述
我正在尝试将当前月份和当前年份放入 HTML 文件中
#!/usr/local/bin/python3
from datetime import datetime
current_month = datetime.now().strftime('%B')
currentYear = datetime.now().year
html_str="""
<br></br>
<caption><b>Project: </b></caption>Client Projects
<br></br>
<caption><b>Issue Type: </b></caption>Managed Services
<br></br>
<caption><b>Summary: </b></caption>OC SPLA usage report for current_month-currentYear
"""
Html_file= open("1.html","w")
Html_file.write(html_str)
Html_file.close()
但作为输出我得到
OC SPLA usage report for current_month-currentYear
代替
OC SPLA usage report for June-2018
解决方案
推荐阅读
- spring-boot - Spring Boot Property Launcher + EhCache 无法读取架构文档
- visual-studio-code - 如何在 VS Code 中使用 ctrl+k 作为快捷方式,而不是作为和弦的开头?
- jenkins - 使用 Jenkins 在多个 Unix 服务器中执行相同的命令
- c - 为什么我的树莓派的串口不可写?write() 写入零字节。select() 超时
- java - 使用套接字从python到Android交换数据时的垃圾值
- javascript - 在网页中与 timeonsitetracker.js API 集成时如何获取实时“timeonsite”参数?
- mysql - 将 MySQL 数据库函数 (?) 与 SQLite (Node.js) 一起使用
- node.js - this._verify 不是登录功能
- reactjs - Redux-form 如何更新 Material-UI v4 textField 值?
- google-cloud-firestore - Javascript Firestore 客户端是否缓存文档引用?