I've three file in pycharm project like,
project
├── main.py
├── parser.py
└── test.py
Both parser.py and test.py have the same code.
def test():
print('test')
But I can only execute main.py with below and it outputs test
from test import test
test()
While when I execute main.py with below,
from parser import test
test()
it output's
Traceback (most recent call last): File "C:/Users/lf/Desktop/jye_parser/main.py", line 1, in <module> from parser import test ImportError: cannot import name 'test' from 'parser' (unknown location) Process finished with exit code 1
Here is the project architecture. I can use Ctrl
+ Left Click
to jump to the test
function in main.py in both case.
It's because parser is a library in python. Use another name for parser file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With