First of all, this is the problem I developed with pycharm4.5, and I'm doing the Python module and function unit example.
Need to build a module named MyModule.
So I wrote one, it's pretty simple.
def arithmetic (X=1 , Y=1 , operator= ) : result={ "+" : X+y, Span class= "hljs-string" "-" : X-y, "*" : x*y, "/" : X/y} return result.get (operator) class myclass : < Span class= "Hljs-keyword" >def myfunc (self) : print ( "MyModule.MyClass.myFunc ()"
)
And then you write a class to call the class that you just
import myModuleif"__main__": mathResult = myModule.arithmetic(2,2,"*") "the math result is :%f" % mathResult print (format) myClass = myModule.MyClass() myClass.myFunc()
Okay, here's the question, so write it, execute the second program, and the result is wrong.
So very simple, according to experience, I refer to the following link
[Python module and import appear importerror:no module named ' xxx ' problem] (http://blog.csdn.net/damotiansheng/article/details/43916881)
Don't say that, it's very helpful. But it's useless.
I have done all the methods I have just linked, and I can't solve this problem by tossing and turning. Placed for 3 days, and suddenly one day I realized it.
See.
If you want to call, you have to ensure that the two files in the project directory, I put them in the basic package, as for why the package can not be put, I still do not understand.
In short, this also solves a big problem.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Python module and import appear importerror:no module named ' xxx ' problem