为什么 PyCharm 在 input() 和 print() 函数中给出错误 - “未解析的引用”?

问题描述

我在项目中的所有其他文件(留下一个特定的)都没有错误

如图所示,只有“Magic-I”的 print()input() 有问题

我会给你完整的代码

outcome = {
    "hi": "Hello","hello": "Hi","what's your name": "Magic-I !","this": "'this' what?","you are mad": "You too.....LEL !!!","your hobby": "Solving problems","fuck off": ".........","i like you": "Me too",}
help = '''
'calculate' - addition ; subtraction ; multiplication ; division.
'car game' - simple car simulator.
'guess game' - launch a simple guessing game.
'rbi' - launch RBI.
'bye' - exit AI
||type 'help' whenever you need to kNow these commands||
*It also chat*
'''

print("----------------------------------------------------------------------------------------------------------")
print("\nThis is an AI - 'MAGIC I' !")
print("It chats and complete several other tasks !")
print("\nSome key features (type these to access them): ")
print(help)

k = ""

while True:
    res = input("\n> ").lower()
    if res in outcome:
        k = outcome.get(res)+" !"
        print(k)
    elif "name" in res:
        print("Magic-I !")

    elif "fuck" in res:
        print('........')

    elif "parent" in res:
        print("Rakshit")

    elif "master" in res:
        print("Rakshit")

    elif "coder" in res:
        print("Rakshit")

    elif "programmer" in res:
        print("Rakshit")

    elif "calc" in res:
        import calculator
        calculator.calculator()

    elif 'car' in res:
        import CarGame

    elif 'guess' in res:
        import GuessGame

    elif 'rbi' in res:
        import RBI

    elif 'ac' in res:
        print("Turn it on !!!")

    elif 'help' in res:
        print(help)

    elif res == "bye":
        print("Bye..!")
        break

    elif res == "":
        print("You haven't typed anything..!")

    else:
        print("No.!")

这是代码......如果你想要别的东西,我可以给你......请帮忙!!!

文件夹:

嘿,当我尝试修复 print() 问题时,它显示了 install print() 包,类似的东西...当我单击它时,出现错误

enter image description here

解决方法

也许你应该删除 ~/.bash_profile 中的 pythonpath 变量 您可以使用以下方法来做到这一点:- #export PYTHONPATH=/usr/local/lib/python2.7/site-packages/