问题
I already refresh DB!
The example can be work.
My problem is IntelliSense is work on line 5, 6
But at the line 7, tree(parameter) can't not find the method xpath()
IntelliSense is not work on line 7, why?
I try to find the answer, someone say need to Removing project __init__.py can fix the problem.
Where is the __init__.py ?
And there exists other good method to solve problem? like: update VS2013?
回答1:
This is actually just a limitation of PTVS. To figure out the type of tree
, it needs to figure out what etree.parse
will return when passed a StringIO
and HTMLParser
. Depending on the code in parse
, this may be near impossible to do without actually executing it.
If you hover over tree
, I suspect you'll see that it is an unknown type. To force it to have a certain type, you can write:
assert isinstance(tree, WhateverType)
This will let PTVS know that it will definitely be of that type, though at runtime your program will crash if you are wrong. When support for type hints is added, you will be able to use those instead (but that will likely require updating to the very latest version of Visual Studio).
来源:https://stackoverflow.com/questions/36602807/ptvs2-1-for-vs2012-intellisense-not-work