zoukankan      html  css  js  c++  java
  • python学习一

    1.下载安装python后打开IDLE编辑器输入抓取百度页面代码

    from urllib import urlopen
    html = urlopen("http://www.baidu.com")
    print(html.read())

    2.写函数

    def printmax(a,b):
        if a>b:
            print a,'is max mum'
        else:
            print b,'is max mun'
    printmax(6,4)

    3.import包含

    4.对象的方法

    class person:
        def sayHi(self):
            print 'hello,how are you?'
    p = person()
    p.sayHi()
    

     5。init相当于php里面的construct,__init__在一个对象被建立时,马上运行

    class person:
        def __init__(self,name):
            self.name =name
        def sayhi(self):
            print 'hello,my name is',self.name
    p = person('swaroop')
    p.sayhi()
  • 相关阅读:
    例6-5
    例6-3
    例6-2
    例6-1
    例5-9
    python3
    python3
    python3
    python3
    python3
  • 原文地址:https://www.cnblogs.com/php0916/p/6694674.html
Copyright © 2011-2022 走看看