![](/img/trans.png)
[英]How to import and use my own function from .py file in Python Pandas?
[英]Import own *.py file from the python shell
我使用名為“test.py”的 vim 在 Python 3 中創建了一個測試文件
def addtwo(one, two):
new = one + two
return new
我將該文件保存在$HOME
目錄中。
然后我通過鍵入python3
打開 Python shell
在 shell 中,我輸入:
from test.py import *
我得到了這個回報:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'test.py'; 'test' is not a package
我認為這是某種文件路徑問題並做了一些谷歌搜索,但我可能沒有正確地表達我的問題。 有人可以透露一些信息嗎?
代替
from test.py import *
它是
from test import *
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.