tensorflow-TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple'問題解決

延續上一篇"Python 3.x中使用print函數出現語法錯誤(SyntaxError: invalid syntax)的原因"
當 print 增加 () 後仍然出現錯誤

After %s iteration(s): x%s is %f.
Traceback (most recent call last):
  File "test9.py", line 14, in <module>
    print ('After %s iteration(s): x%s is %f.') % (i+1, i+1, x_value)
TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple'

解決方式
在印出的外層再加上()
print (("After %s iteration(s): x%s is %f.") % (i+1, i+1, x_value))

留言

這個網誌中的熱門文章

c語言-關於#define用法

CMD常用網管指令

PHP 與 JavaScript 之間傳值利用 json