A.py文件的文件路径为:C:\AmyPython\Test1 B.py中调用A.py文件: import syssys.path.append(r'C:\AmyPython\Test1') #python import模块时,是在sys.path里按顺序查找的。 #sys.path是一个列表,里面以字符串的形式存储了许多路径。 #使用A.py文件中的函数需要先将他的文件路径放到sys.path中 import A a...
A.py文件的文件路径: E:\PythonProject\winycg B.py文件: import sys sys.path.append(r'E:\PythonProject\winycg') """python import 模块时, 是在sys.path里顺序查找的。 sys.path 是一个列表,里面以字符串的形式存储了许多路径。 使用A.py文件中的函数需要先将他的文件路径放到sys.path中 """ import...
python调用其他文件中的函数或者类 1 .在同一个文件夹下,调用函数或者类 A.py文件中 def test(): print('this is test func') class A: def test(): print('this is a class named A, its func is test() ') 1. 2. 3. 4. 5. 6. B.py文件中 # way 1 from A import test from A impo...