这是 Jlaix 的第一篇博客
- 我是 Jlaix, 2年代码经验,曾经写过单片机、Android,早就混迹于优快云,但一直无甚贡献… 最近学 Python ,希望能将学习过程记录一二,欢迎交流、指教~
语法
- python的语法很简单,但是需要注意代码的对齐。基本操作如下:
a = 1
b = 22.2
c = a + b
print(c)
score = 75
if score >= 80:
print("优秀")
elif score >= 60:
print("及格")
else:
print("不及格")
for i in range(0,3):
print("Item {0},{1} (第{2}条)".format(i," Hello python!",i))
def max(a, b):
if a >= b:
return a
else:
return b
print("更大的值是: {0}".format(max(4,12)))
class Father:
def __init__(self, height):
self._height = height
def height(self):
print("父亲身高:{0}".format(self._height))
class Son(Father):
def __init__(self,height):
Father.__init__(self,height)
def height(self):
print("儿子身高:{0}".format(self._height))
father = Father(180)
print(father.height())
son = Son(182)
print(son.height())
import lib
h = lib.Hello("Jlaix 1 号")
h.sayHallo()
from lib import Hello
h = Hello("Jlaix 2 号")
h.sayHallo()