我正在研究Python的概要文件(Rs)的文档。我在Win10笔记本电脑上使用Anaconda的Python3.6。
https://docs.python.org/3/library/profile.html
import cProfile
import re
cProfile.run('re.compile("foo|bar")')根据文档,这不会执行任何问题。
然而,
import pstats
from pstats import SortKey结果出现此错误消息:
ImportError: cannot import name 'SortKey'在这个版本的pstats:https://github.com/python/cpython/blob/master/Lib/pstats.py中有一个https://github.com/python/cpython/blob/master/Lib/pstats.py
但是,当我查看本地pstats.py文件时,我没有这个类,例如,~\AppData\Local\Continuum\anaconda3\envs\py36\Lib\pstats.py与(cPython) pstats.py非常不同。
我想我遗漏了一些明显的东西..。
发布于 2018-11-26 22:44:36
问题是Python3.6vs Python3.7。
3.6,无SortKey:https://docs.python.org/3.6/library/profile.html
3.7,使用SortKey:https://docs.python.org/3.7/library/profile.html
在docs中使用整数默认为最新版本,例如3.7,当我需要3.6的文档时。
https://stackoverflow.com/questions/53490248
复制相似问题