Today wrote the first Python code, very bothered, because the space alignment is not correct, how can not run out, but very excited is finally in my efforts, with the results. And thank God for taking me to the first Python project.
Look at the code first:
#!/usr/bin/python #if__name__ = "__main__" #print "hello, world!" #age =10#name= "Bill" #print '% s is % d years old '% (Name,age) class Student: #类名首字母要大写, other letters in lowercase __name = "" # The private instance variable must have two underscores before def __init__ (self,name): self.__name=name # Self is equivalent to the thisdef getname (self):return self.__name #方法名首字母用小写 in C + +. The first letter of each word is then capitalized if __name__ == "__main__": #相当于C语言的mian函数student = student ("Yang") # Object name in lowercase letter print student.getname ()
Operation Result:
Yang
Python features: 1. Object-oriented features (elimination of protection types, abstract classes, interfaces and other aspects of object-oriented elements);
2. Simplicity (less reserved words, no semicolons, begin,end, etc.), code blocks using spaces or tabs
indentation, delimited code,)
3. Built-in data structure
4. Robustness
5. Cross-platform
6. Extensibility
7. Dynamic Nature
8. Strongly typed languages
9. Widely used
This article from the "Learning Record" blog, reproduced please contact the author!
The first Python code