我正在编写python代码,这给了我一个错误,说一个空格是无效的总管,请看:
from './getinput.py' import getInput as getInput
并显示此错误:
line 1
from './getinput.py' import getInput as getInput
^
SyntaxError: invalid syntax
我不知道该怎么办,你们能给我些帮助吗?这是一些必要的代码,让我们从我的主文件开始:
def WhereDoIStart():
print("Hi! How are you? Whats your name?")
name = input()
print('''Well, '''+name+''' i hope you're doing well! This here is not the text i have, but i can include it's features! it has somethings like this: "+", "-", "*", "/"''')
getInput()
WhereDoIStart()
这里我有getinput.py中的内容:
def getInput():
Userinput = input(">: ")
return Userinput
答案 0 :(得分:1)
摘自Python导入系统的文档
https://docs.python.org/3/reference/import.html
第5.4.2节“子模块”,翻译为您的示例: 是否存在以下文件夹结构
spam/
__init__.py
getinput.py
您可以按以下方式导入getinput模块的功能:
from .getinput import getInput as getInput