python:io.UnsupportedOperation: not readable

f = open('test.txt', 'w')

content = f.read(1)

print(content)

报错:

io.UnsupportedOperation: not readable

原因:

文件没有读权限

解决:

赋予读权限

f = open('test.txt', 'r')

content = f.read(1)

print(content)

 

你可能感兴趣的:(python,python)