Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python-%s%f%d%等_Python_Python 3.x - Fatal编程技术网

Python-%s%f%d%等

Python-%s%f%d%等,python,python-3.x,Python,Python 3.x,我是python新手,我上过这个网站: 突然,在底部出现了像%f%d%s%这样的字符。 有人知道这是什么意思吗?这是一个练习: 正如它所说,%s(指字符串)是替换字符串,%f(指浮点)是替换浮点,%d(指整数)是替换整数 # change this code mystring = "hello" myfloat = 10.0 myint = 20 # testing code if mystring == "hello": print("String: %s" % mystring)

我是python新手,我上过这个网站: 突然,在底部出现了像%f%d%s%这样的字符。 有人知道这是什么意思吗?

这是一个练习:

正如它所说,%s(指字符串)是替换字符串,%f(指浮点)是替换浮点,%d(指整数)是替换整数

# change this code
mystring = "hello"
myfloat = 10.0
myint = 20

# testing code
if mystring == "hello":
    print("String: %s" % mystring)
if isinstance(myfloat, float) and myfloat == 10.0:
    print("Float: %f" % myfloat)
if isinstance(myint, int) and myint == 20:
    print("Integer: %d" % myint)
以下是练习:

正如它所说,%s(指字符串)是替换字符串,%f(指浮点)是替换浮点,%d(指整数)是替换整数

# change this code
mystring = "hello"
myfloat = 10.0
myint = 20

# testing code
if mystring == "hello":
    print("String: %s" % mystring)
if isinstance(myfloat, float) and myfloat == 10.0:
    print("Float: %f" % myfloat)
if isinstance(myint, int) and myint == 20:
    print("Integer: %d" % myint)

这里有一个链接指向同一网站上的解释:只是一个提示,不要使用这个符号
.format()
和f-string在Python 3中是首选。请注意,Python还支持一种较新的字符串格式,通过其内置的string方法不使用
%
。好的,我会注意到这一点。这里有一个链接指向同一网站上的解释:只是一个提示,不要使用此符号
.format()
和f-strings在Python 3中是首选。请注意,Python还支持一种新的字符串格式,它不通过内置的string方法使用
%
。好的,我会注意这一点。