zoukankan      html  css  js  c++  java
  • 2019/11/02 今日小结

    现在如果你写一个程序与用户交互

    输入

    python2:input一定要声明你输入的类型

    input(“》》:”)

    》》:sean

    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "<string>", line 1, in <module>
    NameError: name 'sean' is not defined

    >>> input(">>:")

    >>:"sean"

    "sean”

    >>>raw_input(">>")

    >>:sean

    “Sean”

    >>>raw_input(">>:")

    >>:12

    "12"

    python3:

    name = input("请输入您的名字;")     #接收用户的输入,无论用户输入的是什么类型

    print(name)

    print(type(name))

    print(name)

    总结:

    python2中的raw_input与python3中input作用相同

    2、基本数据类型

    数据:描述、衡量数据的状态

    类型:不同的事物需要不同的类型存储

    int

    python2:分为整型和长整型  如果在合格范围内,就是int

    如果不在这个区间,就是long长整型

    python3:int

    folat:浮点型

    str

    python2:

    str本质就是8个bit位的序列

    python3:

    str本质就是Unicode的序列

    list

    dict

    bool

    3、格式化输出

    1、%s   %d

    %s   可以接受任意类型的变量

    %d   只能接受数字类型的变量

    “my name is xxx,my age is xxx”

    print("my name is %s,my age is %s”%(name,age))

  • 相关阅读:
    TC字符界面菜单程序【原创】
    图片定时自动播放
    根据登录的不同权限,登录不同的窗口!
    html布局
    sprig 的基本使用方法和运用领域
    hibernate的链接数据库的基本步骤
    Jquery
    Java链接数据库的基本步骤
    ajax
    SQL索引的初步使用
  • 原文地址:https://www.cnblogs.com/medigrat/p/11783474.html
Copyright © 2011-2022 走看看