卅向东 发表于 2021-12-28 22:43:45

求解

在终端依次输入下列代码,最后那条指令不能正确执行,显示错误代码“Traceback (most recent call last):
File "<pyshell#54>", line 1, in <module>
    print(open(f.name,'r').read())
PermissionError: 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"}]>

heidern0612 发表于 2021-12-29 12:36:58

错误提示请求拒绝,是不是C盘权限的事呢?
页: [1]
查看完整版本: 求解