Home > other >  For why I can't python import custom class?
For why I can't python import custom class?

Time:10-08

Can you help to see what is wrong, threaddown import failure
Do is a multi-threaded download

CodePudding user response:

You can't do this import, import shall take the file name, if not a directory below still have to take a relative path,

CodePudding user response:

reference 1st floor Sound_of_ Silence response:
you can't do this import, import shall take the file name, if not a directory below still have to take a relative path,

But my class is written in the book of the same py files, written in the above code, why can import

CodePudding user response:

reference 1st floor Sound_of_ Silence response:
you can't do this import, import shall take the file name, if not a directory below still have to take a relative path,

47th line is threaddown class

CodePudding user response:

Import are different files, both of you in the same file,
You put 80 lines used to separate build a py files, and then try again in the back of the import

CodePudding user response:

refer to the second floor () response:
Quote: refer to 1st floor Sound_of_ Silence response:
you can't do this import, import shall take the file name, if not a directory below still have to take a relative path,

But my class is written in the book of the same py files, written in the above code, why can import

The same file doesn't have to import, the direct call

CodePudding user response:

refer to fifth floor Sound_of_ Silence response:
Quote: refer to the second floor () response:
Quote: refer to 1st floor Sound_of_ Silence response:
you can't do this import, import shall take the file name, if not a directory below still have to take a relative path,

But my class is written in the book of the same py files, written in the above code, why can import

The same file doesn't have to import, the direct call good

Is the import directly to delete the line

CodePudding user response:

Try the module name can't use digital beginning,
5. Py change,

CodePudding user response:

yellow elder brother Python training reference 7 floor response:
try module name can't use digital beginning,
5. Py modification

Still won't do
I use this app # CSDN# found have technical content of the blog and friends to seek common to "help", gathered together at https://blog.csdn.net/fhfhfhi/article/details/103448134? Utm_source=app

CodePudding user response:

reference 1st floor Sound_of_ Silence response:
you can't do this import, import shall take the file name, if not a directory below still have to take a relative path,

Now they are in the same directory
The import right, thank you bosses
I use this app # CSDN# found have technical content of the blog and friends to seek common to "help", gathered together at https://blog.csdn.net/fhfhfhi/article/details/103448134? Utm_source=app

CodePudding user response:

refer to the eighth floor () response:
Quote: brother huang Python training reference 7 floor response:
try module name can't use digital beginning,
5. Py modification

Still won't do
I use this app # CSDN# found have technical content of the blog and friends to seek common to "help", gathered together at https://blog.csdn.net/fhfhfhi/article/details/103448134? Utm_source=app



Filename to use Numbers beginning, anyway is a mistake,

Still won't do, then try the following

The import sys
Sys. Path. Append (" the full path of the imported module ")

If not yet, trying again,
  • Related