data = self.cmd("r.out.gdal in=rdata out=geo{0}.tif".format(i))
self.dataOutTIF.setValue("geo{0}.tif".format(i))
str.format(*args, **kwargs)
Perform a string formatting operation. The string on which this
method is called can contain literal
text or replacement fields delimited
by braces {}. Each replacement field
contains either the numeric index of a
positional argument, or the name of a
keyword argument. Returns a copy of
the string where each replacement
field is replaced with the string
value of the corresponding argument.
>>> "The sum of 1 + 2 is {0}".format(1+2)
'The sum of 1 + 2 is 3'
See Format String Syntax for a description of the various formatting
options that can be specified in
format strings.
This method of string formatting is the new standard in Python 3.0, and
should be preferred to the %
formatting described in String
Formatting Operations in new code.
如果您使用的是Python3,那么就可以使用F-string。这里有一个例子
在这种情况下,输出如下:
在接收到的数据中找到元素“记录”
可以使用运算符
%
将字符串注入字符串:这将提供:
您还可以使用
%d
进行整数运算:相关问题 更多 >
编程相关推荐