Discuss / Python / 学习问题

学习问题

Topic source

迷人去年

#1 Created at ... [Delete] [Delete and Lock User]
 'Hi, %s, you have $%d.' % ('Michael', 1000000)

我想问一下括号前面的%起什么作用呢

下雨

#2 Created at ... [Delete] [Delete and Lock User]

格式化字符串啊

%s 表示格式化为字符串(string)

%d 表示格式化为数字(digital)

另外还有:

%f 浮点(float)

%o 八进制

%x 十个进制


  • 1

Reply