首页 > 代码库 > Python语法

Python语法

#coding:gbkfrom pip._vendor import requestsscore=20;if score>=80:	print("很好")elif score>=60:	print("及格")elif score>=30:	print("不及格")else:	print("你成绩很烂")for i in range(0,10):	print("我是循环练习1---{0}".format(i));def sayHello():	print("hell 我是方法");def Max(a,b):	if a>b:		return a	else:		return bsayHello()print( Max(10,20))# python对象class Hello:	def sayHello(self):		print("Hello")h=Hello()h.sayHello();#构造方法class HelloTwo:	def __init__(self,name):		self._name=name	def sayHello(self):		print("Hello{0}".format(self._name))h=HelloTwo("hello极客学院")h.sayHello();class Hi(HelloTwo):	def __int__(self,name):		HelloTwo.__init__(self,name)	def sayHi(self):		print("Hi	{0}".format(self._name));h=HelloTwo("hello极客学院")h.sayHello();hi=Hi("我是继承构造方法实例")hi.sayHi()#第一种引用外部文件方法import mylibh=mylib.hello();h.sayHello();#第二种引用外部文件方法from mylib import helloh=hello();h.sayHello();

  运行效果图:

技术分享

Python语法