|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
在终端依次输入下列代码,最后那条指令不能正确执行,显示错误代码“Traceback (most recent call last):
File "<pyshell#54>", line 1, in <module>
print(open(f.name,'r').read())
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\afuming\\AppData\\Local\\Temp\\tmpvpve_uxn'”
<>>>import tempfile #临时文件模块
>>> data
[{'lang': ('python', 'english'), 'age': 40, 'name': 'qiwsir'}]
>>> f = tempfile.NamedTemporaryFile(mode='w+')
>>> json.dump(data, f)
>>> f.flush()
>>> print (open(f.name, "r").read()) #此处需要如何处理才能正确打印呢???
[{"lang": ["python", "english"], "age": 40, "name": "qiwsir"}]> |
|