zoukankan      html  css  js  c++  java
  • Python基础

    Python基础整理

    1.数据类型

    整数  a = 1
    浮点数  a = 1.1 
    布尔  a = True
    字符串  a = 'hello'  
    转义字符  a = 'hello 换行转义字符'
    数组

    a = ['jack', 'rose']   //数组

    a.append['mary']   //数组追加一个元素

    a.insert(0,'one')    //指定位置加入一个元素

    a[0]='update'       //修改

    a.pop(0)              //删除指定位置的元素,默认删除尾元素

    元组  a = ('jack', 'rose', 'mary')
    字典 a={1:'Jack',2:'Bob',3:'Marry',4:'Micle'}

    a[5]='5'          //增加新的键值对

    a[2]='Harry'       //修改

    del a[1]      //删除某一个键值对

    a.clear()     //清空字典全部内容

    del a        //删除字典

    2.if,for,while

    if

    if score>=80:
      print("Score is A")
    else:
      print("score is not A")

    for

    student=['Jack','Bob','Marry','Micle']
    for stu in student:
      print(stu)

     while  

    n=10
    while n>0:
      n=n-1
      print(n)

    3.类和对象

    class A():
      def __init__(self,n,m):
        self.n=n
        self.m=m
        print("%s and %s" % (n, m))

      #函数B()

      def B(self):
        print("Hello")

    生成实例对象 a1=A('jack','rose')
    a1.B()
    a2=A('rose','mary')
    a2.B()



  • 相关阅读:
    截屏 多难未遂
    捕捉异常
    Android中缓存记忆
    Android中的线程池
    悄悄为Android中解决部分适配问题哦!
    java中的服务端跳转与客户端跳转区别与联系
    doget(),doput()方法的使用
    基本概念--同步,异步
    java--SimpleDataFormat类
    java--9
  • 原文地址:https://www.cnblogs.com/bf-blackfish/p/11424271.html
Copyright © 2011-2022 走看看