企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
1、format(),为要插入的变量留出一个空间 ``` greeting = "Good {},{}.How are you doing" name = "sanqian" time = "morning" print greeting.format(name,time) ``` 2、format(),加入带有键的花括号 ``` specials_text = "Good {time}! Today's specials are:{special} and {special2}" time = "afternoon" food1 = "spam with eggs" food2 = "eggs with spam" print specials_text.format(time = time,special = food1,special2 = food2) ``` 3、format(),变量位置用整数来填充![] ``` line = "cities with python meeet-ups:{0},{1},{2}" print line.format("district of columbia","portland","and many more!") ```