我有以下代码:
Integration_Minute = 00
Integration_Schedule = '''{"cluster":{"scheduling":{"shutdownHours":{"isEnabled":true,"timeWindows":["Sat:00:00-Mon:04:xx","Tue:00:00-Tue:04:xx","Wed:00:00-Wed:04:xx","Thu:00:00-Thu:04:xx","Fri:00:00-Fri:04:xx"]}}}}'''
print(Integration_Schedule.replace("xx", Integration_Minute))
我想用00来代替xx,但是不行。在python中最好的方法是什么? 我得到的错误是:
File "s.py", line 4, in <module>
print(Integration_Schedule.replace("xx", Integration_Minute))
TypeError: expected a character buffer object
问题来源StackOverflow 地址:/questions/59385220/replace-a-char-in-string-within-triple-ticks-in-python
Integration_Minute = '00'
>>> print(Integration_Schedule.replace("xx", Integration_Minute))
{"cluster":{"scheduling":{"shutdownHours":{"isEnabled":true,"timeWindows":["Sat:
00:00-Mon:04:00","Tue:00:00-Tue:04:00","Wed:00:00-Wed:04:00","Thu:00:00-Thu:04:0
0","Fri:00:00-Fri:04:00"]}}}}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。