open(logPath, 'r') as fh 的语法错误:
Syntax Error with open(logPath, 'r') as fh:
with open(logPath, 'r') as fh:
for line in TailDeque(fh, 20):
gamethread.delayed(0, show_recentlyCommands, (userid, text))
我总是在行 with open(logPath, 'r') as fh:
中收到错误
我正在使用 Python 2.5 并使用 TailDeque。
Python 2.5 只支持可选的with
语句;您需要将其作为 each 文件中的 first 行,该文件使用 with
语句:
from __future__ import with_statement
with
语句无需 __future__
导入即可工作,因为 Python 2.6
with open(logPath, 'r') as fh:
for line in TailDeque(fh, 20):
gamethread.delayed(0, show_recentlyCommands, (userid, text))
我总是在行 with open(logPath, 'r') as fh:
我正在使用 Python 2.5 并使用 TailDeque。
Python 2.5 只支持可选的with
语句;您需要将其作为 each 文件中的 first 行,该文件使用 with
语句:
from __future__ import with_statement
with
语句无需 __future__
导入即可工作,因为 Python 2.6