问题标签 [python-3.3]
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.
python - Python 3.3 的模块 _ssl 导入错误
我在最新版本的 Ubuntu 上使用 Python 3.3 编程。我正在为一个涉及与 Twitter 一起使用的库的项目编写代码。这是我拥有的终端的输出:
我一直在寻找解决 _ssl 错误的方法,但似乎找不到我可以遵循的方法。
python - 如何在 Python3 中使用 datetime 将天数转换为月数?
有没有一种特殊的方法可以得出这个,还是我们必须创建循环?这个函数的参数实际上是(year, num_of_days)。但我不知道如何从中得出几个月。这是我到目前为止所拥有的(不完整),但它没有考虑到不同的月份。有没有更简单的方法来解决这个问题?提前致谢!
python - 在 Python 中数到 10 亿的最快方法
没有很多python /编程经验。我需要测试 1 到 10 亿之间的每个数字,然后将某些数字附加到列表中。目前我正在尝试使用 range( 0 , Billion ) ,但我发现在我的机器上使用 Python 3.3 大约需要 80 秒。有没有更有效的方法来做到这一点?
python - 使用 functools.lru_cache 时达到最大递归深度更快
我一直在玩 python 3.3 中的记忆和递归
忽略 python 是错误的语言这一事实,我发现在使用 functools.lru_cache
记忆和不使用之间我得到不一致的结果 functools.lru_cache
我没有更改递归限制 - 它保持默认值,对我来说是 1000。
为了测试这个问题,我编写了一个简单的递归函数来对从 1 到 i 的数字求和
正常运行这个函数,我可以在sumtil(998)
不达到递归限制的情况下舒适地运行。sumtil(999)
或以上将抛出异常。
但是,如果我尝试用 装饰此函数,则在运行时会提前 3 次@functools.lru_cache()
抛出递归限制异常sumtil(333)
由于 332*3 = 996,但 333*3 = 999,在我看来, lru_cache 装饰器导致我的函数中的每个递归级别变成了三个递归级别。
functools.lru_cache
为什么我在使用记忆函数时得到三倍的递归级别?
python - 导入 numpy 可与解释器一起使用,但不能完全与 python 中的 pyscripter 一起使用
我正在使用 python 3.3 (x64) 和 pyscripter 2.5.3 (x64),python 3.3 (x64) 的 numpy 1.7。当我在脚本中导入 numpy 时,我没有 numpy 的所有功能,只有少数几个(不是很多,也不是 array )?好像它无法从 numpy 导入所有文件
如果我使用 IDLE,它可以正常工作,与 notepad++ 相同。
python - 全局变量问题 Python
如果我今晚很愚蠢,我不会这样做,但由于某种原因,这在 Python 中不起作用。我正在尝试在python中的函数中设置变量,每当我打印它们时,我都会得到一个“函数+函数名称+十六进制值而不是字符串”,任何人都可以给我一些建议吗?
谢谢
python - Argparse:如何接受具有不同“类型”的参数
我想接受以下风格的参数:
到目前为止,我已经完成了以下操作(添加了参数 -r 并定义了类型 revs)。它应该传回两个列表,这可能有问题。
使用上述运行时出现以下错误:
ValueError:“revs”不可调用
sublimetext2 - 崇高文本2 Windows 7上的python 3.3
我正在运行 Windows 7 32 位并且我正在使用 sublime text 2 我想知道如何将 ST2 中的默认 python 更改为我下载的 python 3.3。任何帮助都会非常感谢。
python - Synchronize local array with (SQLite) table
I have an object that has three methods:
load()
: Loads database table's contents into a local object-attribute-listadd()
: adds an element to the listremove()
: removes an element from the listsave()
: Synchronizes the list with the database (this is where my question lies, details follow)
The first three methods are straight forward. But to synchronize the data back to the database-table, I want
- those elements that have changed to be
UPDATE
d/REPLACE
d - those that are new in the list and don't exist in the db table to be
INSERT
ed - those that are removed from the list but still exist in the db-table to be
DELETE
d
Is there a way to do all that magic in one incredibly-elegant SQL command or would I need to do it in two steps, such as
INSERT OR REPLACE...
first, thenDELETE FROM ... WHERE ...
?
Any ideas or suggestions would be much appreciated. Please excuse me if there is an obvious solution to this that I have missed.
matplotlib - 散点图 X 轴上的日期标签
所以我刚刚安装了 Python3.3、Numpy、MySQL Connector 和 Matplotlib。我有一个包含大量数据的表,我在其中编写了一个查询,将其输出为类似于以下内容:
因此,通过大量的试验和错误并将教程和其他问题拼凑在一起,我最终得到了这个 python 脚本:
我有很多数据点会重叠(相同的坐标),所以我希望 alpha 真的很低。我在这里得到了我想要的:
无论如何,我想要的是简单地将刻度标记格式化为日期(例如月、年)。我在这个问题上进行了很多搜索,并在这里找到了一个类似的问题,但是我无法对其进行调整或理解如何将其应用于我的脚本。这么简单的事情似乎过于复杂?