您的位置:首页 > 编程语言 > Python开发

Python常见问题处理

2014-12-28 10:33 316 查看
1:Unused import

环境:Ubuntu 14.04 eclipse 3.8

eclipse环境下利用PyDev插件做开发的时候,输入:import re,左边会出现一个黄色的警告,属标放上去后会显示:Unused import re

原因如下:(ref:http://stackoverflow.com/questions/16394732/unused-wild-import-why)

That message just tells you that you are importing features from a module that you don't need, which means you should probably import just what you need. You shuld simply use
from foobar import x, y
where
x
and
y
are the elements you actually need.The syntax
from foobar import *
is more useful in the command-line interpreter when you don't want to think or type many more characters for little benefit. But in a real project, you should not use that syntax since if you use it, it will not be clear which feature from the module you are going to use.

也就是说:只import re 而没有使用 re,等后面使用到re的方法时候,这个警告自然会消除
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: