I have a Python project with 2 files: epic.py site.py
in the epic.py I have the lines
from site import *
bark()
in site.py I have the lines
def bark开发者_如何学C():
print('arf!')
when I try to run epic.py, it returns "bark is not defined"
this is weird.Try renaming site.py to mysite.py or something like that because there is a standard Python site
module.
That's because site
is also the name of a built-in module. You weren't really importing your custom site
module. If you change the name to, say, site_.py
and import accordingly, it'll work.
精彩评论