【发布时间】:2012-04-10 14:35:31
【问题描述】:
FileName = 'Binarydata.dat'
BinaryFile = open(FileName, 'r')
for '0' in BinaryFile:
print('')
else:
print('@')
BinaryFile.close()
我在尝试运行此代码时收到错误 SyntaxError - can't assign to literal。这只是代码的一小部分。其余的工作正常。我不知道为什么这不起作用。
【问题讨论】:
-
你到底要来这里做什么?使用
'0'作为 for-each 变量没有特别的意义...? -
您要查找的是 BinaryData 中的 x:如果 x 为 0:print('')
-
I can't figure out why this is not working.那也许你可以试试learnpythonthehardway.org
标签: python