如何使用PYYAML更新yaml文件?
我如何
使用Python(PyyAml软件包)评论“ driverClassName ”行和更新 org.quartz.threadpool.threadcount 200至200至200?
PRODUCT_HOME: /app
config:
active-profiles: mysql,oauth2
driverClassName: com.mysql.cj.jdbc.Driver
datasourceurl: jdbc:h2:file:./data
datasourceuser: sa
spring:
quartz:
job-store-type: jdbc
enabled: true
properties:
org.quartz.threadPool.threadCount: 50
How can I comment the 'driverClassName' line and update org.quartz.threadPool.threadCount to 200
In the YAML snippet below, using python (PyYAML package)?
PRODUCT_HOME: /app
config:
active-profiles: mysql,oauth2
driverClassName: com.mysql.cj.jdbc.Driver
datasourceurl: jdbc:h2:file:./data
datasourceuser: sa
spring:
quartz:
job-store-type: jdbc
enabled: true
properties:
org.quartz.threadPool.threadCount: 50
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Pyyaml无法添加评论。它实际上删除了有关加载的所有评论,因此一般而言Pyyaml
不是需要进一步人类互动的YAML文档的合适工具(这
我认为是添加评论的原因)。
您应该使用
ruamel.yaml
(免责声明:我是该软件包的作者):
PyYAML cannot add comments. It actually removes all comments on loading, so in general PyYAML
is not the appropriate tool for YAML documents that need further human interaction (which
I assume is the reason for adding a comment).
You should do this with
ruamel.yaml
(disclaimer: I am the author of that package):which gives: