我有一个程序(Python3.6)包含一个.py文件(我想这就是所谓的脚本),我用PythonBasicIDE3.6编写,然后我在shell中尝试,最后我用它在.py文件中生成double clic。
现在,我遇到了Eclipse(使用PyDev),现在我在这个IDE中编写代码。我了解到我可以将我的程序分割成几个.py文件以使程序更有条理,然后我发现我可以使用多个包和多个.py文件来使一切更有条理。
实际上我的计划是:
Game
/.settings # I didn't make it folder...
/org.eclipse.core.resources.prefs # ????
/core # "main" package.
/__pycache__ # I didn't make this folder but it have a lot of files that i used to use (put their are .pyc not .py). Can i delete them???
/__init__.py # I don't use it for now, but i read that all __init__.py files are very important... right?
/main.py # This was my first file, for my this is the core, this file imports all the others, when i run the program in eclipse, i run this file. When the program was only a file, it was the file.
/name_Data.csv
/registration.py
/functions # package with only functions (def)
/__pycache__
/__init__.py
/functions.py
/variables # package with only variables (config...)
/__pycache__
/__init__.py
/config.py
/variables.py
/.project # I didn't make it file...
/.pydevproject # I didn't make it file....
游戏文件夹也存储在:
Workspace
/Python
/Game
/.metadata # ???
/.mylyn
/.taskListIndex
/segments.gen
/segments_1
/contexts
/.task.xml.zip
/repositories.xml.zip
/task.xml.zip
/.plugins
... a lot of folders org.eclipse.jdt. etc...
/.back_0.log
/.lock
/.log
/version.init
现在当我测试我的代码时,我总是从eclipse运行它(我不再使用pythonide了),但是今天下午我试着打开在中生成doble clic的程序主.py它不起作用,在pythonide中也不起作用。当我制作doble clic时,它会打开一个python控制台(对不起,我的知识水平很低,我认为这叫做Shell)一秒钟,然后在python IDE中打开时关闭(不打印任何内容),然后打印:
Traceback (most recent call last):
File "C:\Users\####\Desktop\Extra\Workspace\Python\Game\core\main.py", line 25, in <module>
from variables import variables as var
ModuleNotFoundError: No module named 'variables'
没有日蚀我怎么能打开它? 另外,我要一份主.py文件在包外还是在核心包内?你知道吗
从变量.py导入变量
应该可以了。(我想)
你可以用
示例
你知道吗变量py你知道吗
你知道吗主.py你知道吗
当你跑的时候主.py它会打印“你好”
编辑:仔细阅读错误消息后,会发现这是因为文件位于不同的文件夹中
在我昨天刚做的一个项目上解决这个问题
我有以下工作区
测试/
>;测试.py你知道吗
你知道吗联系人度量.py你知道吗
导入联系人度量.py我必须做以下事情
相关问题 更多 >
编程相关推荐