Swampy.1.1与Python 3(Swampy.1.1 with Python 3)

编程入门 行业动态 更新时间:2024-10-28 15:33:52
Swampy.1.1与Python 3(Swampy.1.1 with Python 3)

我正在阅读Allen Downey的Think Python一书。 对于第4章,必须使用一套称为Swampy的模块。 我已经下载并安装它。

问题是这些模块是用Python 2编写的,我有Python 3(在Windows 7 RC1中)。 当我从Swampy运行TurtleWorld模块时,我得到了关于print和exec语句的错误消息,这些语句现在是Python 3中的函数。我通过在GUI和World模块的代码中包含带有print和exec的括号来修正了这些错误。 我也遇到了一个错误,说明找不到Tkinter模块。 事实证明,在Python 3中,模块名称拼写为小写字母t。

第三个错误更困难:ImportError:没有名为tkFont的模块。

有谁有任何想法吗? 谢谢。

I am reading the book Think Python by Allen Downey. For chapter 4, one has to use a suite of modules called Swampy. I have downloaded and installed it.

The problem is that the modules were written in Python 2 and I have Python 3 (in Windows 7 RC1). When I ran the TurtleWorld module from Swampy, I got error messages about the print and exec statements, which are now functions in Python 3. I fixed those errors by including parentheses with print and exec in the code of the GUI and World modules. I also got an error that the Tkinter module could not be found. It turned out that in Python 3, the module name is spelled with a lower case t.

The third error is more difficult: ImportError: No module named tkFont.

Does anyone have any idea, please? Thank you.

最满意答案

Python 3尚未重写许多重要的第三方库; 现在你必须坚持使用Python 2.x。 没有其他办法了。 正如它在官方Python下载页面上所说的那样,

如果您不知道要使用哪个版本,请从Python 2.6.4开始; 现在更多的现有第三方软件与Python 2兼容。

Many important third-party libraries have not yet been rewritten for Python 3; you'll have to stick to Python 2.x for now. There is no way around it. As it says on the official Python download page,

If you don't know which version to use, start with Python 2.6.4; more existing third party software is compatible with Python 2 than Python 3 right now.

更多推荐

本文发布于:2023-07-26 19:55:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1280304.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Swampy   Python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!