Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/323.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
属性错误:';非类型';对象没有属性';格式';在python3.4中_Python - Fatal编程技术网

属性错误:';非类型';对象没有属性';格式';在python3.4中

属性错误:';非类型';对象没有属性';格式';在python3.4中,python,Python,上述代码中有一个错误: predictions = getPredictions(summaries, testSet) accuracy = getAccuracy(testSet, predictions) print('Accuracy: {0}%').format(accuracy) 应该是 print('Accuracy: {0}%').format(accuracy) AttributeError: 'NoneType' object has no attribute 'forma

上述代码中有一个错误:

predictions = getPredictions(summaries, testSet)
accuracy = getAccuracy(testSet, predictions)
print('Accuracy: {0}%').format(accuracy)
应该是

print('Accuracy: {0}%').format(accuracy)
AttributeError: 'NoneType' object has no attribute 'format'

尝试将格式应用于“精度:{0}%”,然后在python 3.4中打印它,打印函数需要打印任何语句。此功能将输出打印到标准输出控制台并返回None。在这里,您正在将格式应用于返回打印函数的值。因此它抛出非类型错误

所以对字符串使用格式,而不是返回打印值:-

print('Accuracy: {0}%'.format(accuracy))

print('accurity:{0}%')。format(accurity))
提交新问题之前,请先查看副本或使用谷歌。在此处发布问题时,请列出可能重复的问题;它甚至不允许你在python3.4中发布没有
的问题,因为这个标题已经存在。不仅在python3.4中,
print
在python3中变成了一个函数而不是一个关键字。你可以在python3中获得关于@lmiguelvargasf yes的更多信息,它使用了(),但仔细检查问题,它是关于python 3.4的
print('Accuracy: {0}%'.format(accuracy))