Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/318.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,Windows 10}时出现值错误_Python_String - Fatal编程技术网

执行字符串格式化{Python,Windows 10}时出现值错误

执行字符串格式化{Python,Windows 10}时出现值错误,python,string,Python,String,我的代码: print(“{:以下内容将引发ValueError:未知格式代码异常: n = 8 print("{:<n}world".format("hello")) print(f"{{:<{n}}}world".format("hello")) hello world

我的代码:
print(“{:以下内容将引发
ValueError:未知格式代码
异常:

n = 8

print("{:<n}world".format("hello"))
print(f"{{:<{n}}}world".format("hello"))
hello   world