logo
  • 教程列表
  • SO官方文檔
  • python 中的模板
    • 使用模板的簡單資料輸出程式
    • 更改分隔符
  1. StackOverflow 文件
  2. Python Language 教程
  3. python 中的模板
  4. 更改分隔符

更改分隔符

Created: November-22, 2018

你可以將“$”分隔符更改為任何其他分隔符。以下示例:

from string import Template

class MyOtherTemplate(Template):
    delimiter = "#"

data = dict(id = 1, name = "Ricardo")
t = MyOtherTemplate("My name is #name and I have the id: #id")
print(t.substitute(data))

你可以在這裡閱讀 de docs

  • 使用模板的簡單資料輸出程式

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明