files = []
with open("[...].log", "a+") as posshell:
for line in files:
print(line)
posshell_files.append(line)
我没有任何线索。它什么也不打印。数组为空。我试过抓取每个空字符并删除它们,以防它是 UTF16 -> 打开为 UTF8,没有用。
您将错误的第二个参数传递给以open
这种方式读取文件的调用:
posshell_files = []
with open("posshell.log", "r") as posshell:
for line in posshell:
print(line)
posshell_files.append(line)
根据 Python 文档 for open
,'r'
如果读取 while 的默认标志'a+'
是用于读取和写入,但您必须以不同的方式这样做:
with open("posshell.log","a+") as f:
f.seek(0)
print(f.read())
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句