zoukankan      html  css  js  c++  java
  • 字符串的格式

     字符串的格式:

    name = input("name:")

    info = "xingming : %s"% (name)

    print(info)

    如果换行,则

    name = input("name:")
    age = input("age:")

    info = '''xingming : %s
    age: %s'''
    % (name,age)

    print(info)

    #%d=digit
    #%f=float
    #%s=string

    数字类型

    type(1)

    type(1) is int

    以下情况都是假

    []空列表

    {}空字典

    ()空元组,空集合

    ‘’空字符串

    0

    &运算

    |运算

    60&13=12

     

    异或运算:相同的是0,不同的是1,叫异或运算,60^13=49

     

    按位取反

     

    info= {}

    info=info.fromkeys([1,2,3],{}) #初始化字典
    print(info)

    # 三级菜单

    menu={
        "北京":{
            "海淀":{"五道口","亚运村","中关村",},
            "昌平":{"立水桥","霍营","温泉",},
            "朝阳":{"朝阳公园","团结湖","东四环",},
            "东城":{},
        },
        "上海":{},
        "山东":{},
    }

    exit_flag=False

    while not
    exit_flag: #不为真
       
    for key in menu:
            print(key)

        choice = input(">:").strip()
        if len(choice) == 0:continue
        if
    choice == "q":
            exit_flag = True
            continue
        if
    choice in menu:    #省存在,进入下一级
           
    while not exit_flag:
                next_layer=menu[choice]
                for key2 in next_layer:
                    print(key2)
                choice2 = input(">>:").strip()
                if choice2 == "b": break
                if
    len(choice2)== 0:continue
                if
    choice2 == "q":
                    exit_flag = True
                    continue
                if
    choice2 in next_layer:    #市存在,进入下一级
                   
    while not exit_flag:
                        next_layer2=next_layer[choice2]
                        for key3 in next_layer2:
                            print(key3)
                        choice3 = input(">>>:").strip()
                        if choice3 == "b":break
                        if
    choice3 == "q":
                            exit_flag = True
                            continue


    #切记写重复的代码,太低端,容易被开除

    # 三元运算,不能带elif
    a=3
    b=5
    c=a if a<b else b
    print(c)

    c=a if a<b and a==5 else b
    print(c)

    # 八进制,cot里面输入十进制的数字,得到8进制的结果
    a=oct(8)
    print(a)

    # 16进制,hex里面输入十进制的数字,得到16进制的结果
    b=hex(15)
    print(b)
    b=hex(186)
    print(b)
    # 16进制,0123456789ABCDEF
    # 10=A
    # 计算机底层用的都是16进制
    # BH为后缀或者OX为前缀的数据,都是16进制的数据

    # BF4.B5
    # 1011 1111 0100 . 1011 0101


    # 186
    # 128 64 32 16 8 4 2 1
    # 1   0   1  1 1 0 1 0
    print(186-128-32)
    ba
     

    
    
    
  • 相关阅读:
    ZOJ3213-Beautiful Meadow
    ZOJ3256-Tour in the Castle
    ZOJ3466-The Hive II
    hdu3377-Plan
    fzu1977-Pandora Adventure
    ural1519-Formula 1
    poj2914-Minimum Cut
    51nod-1220-约数之和
    51nod-1222-最小公倍数计数
    【html】【6】div浮动float
  • 原文地址:https://www.cnblogs.com/jensenxie/p/8299315.html
Copyright © 2011-2022 走看看