Python簡単入門文法python基礎入門知識
7177 ワード
1. Hello World
print("Hello Python")# .py print
2. ,
a=10
b=32
c=a+b
print(c)
3.
score=20
if score>=90:
print(" ")
elif score>=80:
print (" ")
elif score>=60:
print (" ")
elif score>=30:
print (" ")
else:print (" ")
4.
for i in range(0,100):
print (i)
for i in range(0, 100):
print ("Item {0}qwertyuiop{1}".format(i,"aaa")) #python
5.
def sayHello():#
print("Hello World")
sayHello()
def max(a,b,c):#
if(areturn b+c
else:return a+c
print(max(10,2,3))
6. :
class Hello:
def __init__(self,name):#
self._name=name# , self._
def sayHello(self):
print ("Hello {0}".format(self._name))# python ,{n} n format
def test(self):
print ("test")
class Hi(Hello):#
def __init__(self,name,desc):
Hello.__init__(self,name)
self._desc=desc
def sayHi(self):
print ("Hi {0}".format(self._name))
def pridesc(self):
print (self._desc)
h=Hello("aaa")
h.sayHello()
i=Hi("asd","qwe")
i.test()
i.sayHello()
i.sayHi()
i.pridesc()
print (i._desc)#
7.外部pythonファイルの導入
import outpython
#導入ファイルhello=outpython.Hello()hello.sayHello()
from outpython
import Hello
#ファイルに導入されたクラスhello=Hello()hello.sayHello()外部ファイルコード:
outpython.py
class Hello:
def sayHello(self):
print ("Hello")
8.python : # ,
Tips:
①Python , , :coding=utf-8
②Pythonファイル拡張子py
③pythonダウンロードアドレス:https://www.python.org/
python統合開発ツール:PyCharm,ダウンロードアドレス:http://www.jetbrains.com/
python Webサイト開発フレームワーク:web 2 pyフレームワーク、Webサイト:http://www.web2py.com/
④python不要;コード行の末尾を行いますが、インデントの要件は非常に厳しいです.