简体   繁体   English

我的python code_非常初学者问题有什么问题吗?

[英]What is the wrong with my python code_ very beginner question?

#!/usr/bin/env python3

class Test: 

    note = 10 

if note >= 10:
            print("yes")
    else:
            print("NO")

The output is: 输出为:

env: /Users/mac/Downloads/Ex_Files_Python_EssT/Test.py: 
Permission denied

Why I have got this message? 为什么我收到此消息?

Make the python file executable 使python文件可执行

chmod +x Test.py chmod + x Test.py

Why do you have to include the logic inside a class? 为什么必须将逻辑包含在类中?

note = 10 注意= 10

if note >= 10: print("yes") else: print("NO") 如果注释> = 10:print(“ yes”)否则:print(“ NO”)

Just this will do, remove the class 这样做就可以删除类

Why you use "env" from system directory? 为什么从系统目录中使用“ env”? If you change first line of script code will working. 如果更改,脚本代码的第一行将起作用。 May be some strange settings in you OS or you try strange using python env. 可能是您操作系统中的某些奇怪设置,或者您使用python env尝试了奇怪的设置。

#!/usr/bin/python2.7

class Test:
    note = 10

    if note >= 10:
       print("yes")
    else:
       print("NO")  

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

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