python的format用法

format用法我理解成了"占位符"

-----------------------------------------------------------------------------


Province='广东省'

city='广州市'

township='白云区'

print("省区:{0},市区:{1},乡镇:{2}".format(Province, city, township))    #注意是.format   不是逗号

-------------------------------------------------------------------------------------------

运行结果:

>>>省区:广东省,市区:广州市,乡镇:白云区

 

#注意占位符号写法,,顺序随你

 

posted @ 2022-02-22 09:29  猴年马月  阅读(73)  评论(0编辑  收藏  举报