简体   繁体   English

PyCharm不显示我的代码的输出

[英]PyCharm does not show the outputs of my code

I am using Pycharm 3.4.1 with Python version 3. For two days my basic/simple codes haven't been working. 我正在将Pycharm 3.4.1与Python版本3一起使用。两天来,我的基本/简单代码一直无法使用。 Pycharm says code executed with 0 mistakes. Pycharm说执行的代码有0个错误。 But there are no prints or results in the end. 但是最后没有印刷品或结果。

Can anyone check the codes? 任何人都可以检查代码吗? Is there anyone who has experienced the same thing? 有没有人经历过同样的事情?

Code 1: 代码1:

#Welcome to basic calculator, let's start..

a = int(input("Enter your first number: "))
b = int(input("Enter your second number: "))

type = str(input("Please choose your calculation type: +, -, *, / "))



if type == "+":
    print("The result is: ", a + b)
elif type == "-":
    print("The result is: ", a - b)
elif type == "*":
    print("The result is: ", a * b)
elif type == "/":
    print("The result is: ", a / b)
else:
    print("The command you entered is not valid")

Code 2: 代码2:

class Enemy:
    life = 3

    def attack(self):
        print('attack!')
        self.life -= 1


    def check(self):
        if self.life <= 0:
            print("I am dead")
        else:
            print(str(self.life) + " life left")



enemy1 = Enemy()
enemy2 = Enemy()


# each object is independent of one another, they don't share variables
enemy1.attack()
enemy1.attack()
enemy1.check()
enemy2.check()

Had the same problem. 有同样的问题。 In my case the anti-virus software (Comodo) hat the file contained and didn't allow it to access the console. 就我而言,防病毒软件(Comodo)包含了该文件,并且不允许其访问控制台。

After setting the file to safe in Comodo the output works fine. 在Comodo中将文件设置为安全后,输出正常。

I had this exact same problem and I'm also a noob with python and pycharm. 我有这个完全相同的问题,我也是python和pycharm的菜鸟。 I followed the JetBrains debugging tutorial and their sample script ThreadSample.py jumped into the debugger and did everything exactly the way it was supposed to. 我遵循了JetBrains调试教程 ,他们的示例脚本ThreadSample.py跳入了调试器,并按照应有的方式进行了所有操作。 But then I spent a couple days trying to debug one of my own python scripts, or even get it to run! 但是后来我花了几天时间尝试调试自己的python脚本,甚至使其运行! (Runs perfectly in IDLE.) What finally worked for me was creating a brand new project, copying only that script into it and now Pycharm does everything it's supposed to with it. (在IDLE中完美运行。)最终对我有用的是创建一个全新的项目,仅将脚本复制到其中,现在Pycharm可以完成它应该做的所有事情。 My working guess was that Pycharm does so much micromanagement with the file system that it got all goobered up when it found my original script in a folder with a bunch of files that didn't have anything to do with python or Pycharm. 我的工作猜测是,Pycharm对文件系统进行了太多的微管理,以至于当它在一个文件夹中找到我的原始脚本时,所有文件都被破坏了,这些文件夹中有一堆与python或Pycharm无关的文件。 Anyway, this worked for me. 无论如何,这对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM