python get set无法用_Python - 无法从集合中导入Set(“无模块命名集合”)

I'm trying to learn python and I was trying to write something simple. I am developing under Pydev (Eclipse) using OS X 10.8. I installed python 3.2 using the 64bits .dmg installer.

I configured the Python interpreter successfully (or I think so, as I actually can create a "hello world" project and run it). But for some reason, when I try to import Set (from sets import Set) I get this error:

from sets import Set;

ImportError: No module named sets

I have tested it on command line too, and gives me the same error.

Then I have looked at the lib folder from my python3 directory (under /Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/) and it's missing sets.py file!!! The original 2.7 version does have it at /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/

I have also tried to copy the 2.7 sets.py to the 3.2, but it neither works...

Please, do you know what have I to do?

解决方案

You don't need the sets module anymore. set is a built-in class in Python 3 and can be used without import.

mySet = set()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值