问题标签 [python-3.6]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
436 浏览

python - 为什么在 Python 3.6 中计算 f"\{10}" 时符号 '{' 仍然存在?

f-string是 Python 3.6 中的新特性之一。

但是当我尝试这个时:

我无法弄清楚为什么左花括号'{'仍然在结果中。我认为结果应该与str.format

PEP-0498中,它没有明确回答这个问题。那么是什么导致左花括号保留在结果中,以及是什么导致了and'{'之间的这种差异?f-stringstr.format()

0 投票
1 回答
2427 浏览

python - 安装Pygame时Python pip3 egg_info错误代码1

我最近得到了 python 3.6,我正在安装 python 包。到目前为止,请求已经奏效,但对于 pygame,我收到一个错误:

安装其他软件包(例如熊猫)时,我遇到了类似的错误,错误可能是软件包还没有为 python 3.6 或其他东西准备好吗?我正在运行 Windows 10 64 位

请帮忙,尼克

0 投票
1 回答
5554 浏览

python - 为 Python 3.6 元类提供 __classcell__ 示例

根据 3.6.0 文档:

CPython 实现细节:在 CPython 3.6 及更高版本中,单元格作为类命名空间中的条目__class__ 传递给元类。__classcell__如果存在,则必须将其传播到type.__new__ 调用才能正确初始化类。如果不这样做,将导致DeprecationWarningPython 3.6 中RuntimeWarning的 a 和未来的 a。

有人可以提供一个正确执行此操作的示例吗?

一个实际需要的例子?

0 投票
3 回答
14324 浏览

python - Python 3.6 pip install matplotlib 和其他库在 Windows 10 上失败

我最近有一台新笔记本电脑,我想安装我所有的 python 库。但是,其中一些只是不会安装,例如 matplotlib。

关于我的电脑:Windows 10 和 Python 3.6,根据 pip,这些库。

“pip install matplotlib”的结果:

基本上,关于缓存文件的一些东西,来自 site.py 的一堆 AttributeErrors 和一些关于没有 freetype 或 png 的东西。我试图修复site.py,但它仍然无法正常工作。我尝试了 PyPi 的 .whl 文件,但它不起作用。我试过“pip install matplotlib --no-cache-dir”,同样的事情。我尝试手动下载 png 和 freetype,但我找不到它们。我想下载的所有其他库都发生了大致相同的情况:NumPy、SciPy、pandas。

0 投票
2 回答
1674 浏览

python - 在 circleci 中使用 Python 3.6.0

我正在使用 python 3.6 开始新项目,我想将 circleci 附加到我的项目中。

我的 circle.yml 是

和circleci错误

似乎 circleci 不支持最新的 pyenv 版本。

我如何解决它?

0 投票
1 回答
357 浏览

mongodb - 使用python将.ogg文件上传到mongodb的编码是什么?

我正在编写一个脚本,用于通过 python 将 .ogg 文件上传到 mongodb。我正在使用python 3.6并且最近刚刚学习,所以我没有任何想法。请帮我。

这是我的代码:


但它说:


我做了一些研究。我知道我必须在里面写编码:将 文件数据流式传输到 mongodb gridfs 所以我也写了 fs.put(fileName,'UTF-8'),我读了这个页面: 编码 它说 ["encoding": encoding used for this文件。在 Python 2 中,写入文件的任何 unicode 都将转换为 str。在 Python 3 中,写入文件的任何 str 都将转换为字节。]

0 投票
1 回答
860 浏览

python - Python 3.6 与 3.5 关于字符串连接的 TypeError 消息

'Hello ' + 1在 Python 3.5 和 3.6 上不会返回相同的错误消息:

  • Python 3.5.2:TypeError: Can't convert 'int' object to str implicitly
  • Python 3.6.0:TypeError: must be str, not int

是简单的措辞变化还是背后有更微妙的东西?

0 投票
1 回答
38110 浏览

python - what does --enable-optimizations do while compiling python?

I'm trying to compile Python 3.6 on an arm based Linux machine, ./configure outputs this:

If you want a release build with all optimizations active (LTO, PGO, etc), please run ./configure --enable-optimizations.

what does --enable-optimizations do?

0 投票
1 回答
3140 浏览

python - 无法从命令行使用 Python 2

我最近尝试卸载 Python 3.5.2 并安装了 Python 3.6.0。我曾经python在命令行中使用从命令行运行 Python 3.5.2,并py运行 Python 2.7.12。现在,python运行 Python 3.5.2,并py运行 Python 3.6.0。我正在运行 Windows 10,并且python3, python2, py2, 并且py3不执行任何操作。

0 投票
1 回答
3141 浏览

python - 如何将 Python 更新到 3.6.0?

最近看到Python的新版本出来了,3.6.0。有没有办法更新我的 Python 3.5.2 版本而不卸载它并下载新版本?