python语言初识(红桃三)

用户输入

   input使用:

     python2 :要声明输入类型    "bigbox"

     python3:   不需要声明输入类型   bigbox

  python2的 raw_input  与 python3 的 input 功能相同

python的基本数据类型

     int :python2  int  longint       python3  int

     float:

     str:python2 str本质是8个bite位的序列     python3 str的本质是unicode的序列

     list:

     dict:

     bool:

字符串格式化输出

   1.%s、%d       print("my name is %s,age is  %d"%(name,age))

   2. .formate()    print("my name is {},age is  18".formate(name))     print("my name is {user},age is  {age}".formate(user=name,age=age)) 

   3.f-string         print(f""my name is {name},age is  {age}")

 运算符

 1.算数运算符(加减乘除,次幂,取整,取余) + - * /  **  //  %

 2.比较运算符 :==  > >= < <=  !=   输出结果为true  false     if  a==b

 3.赋值运算符:a=b ,

 4.交叉运算符; a,b = b,a

 5.增量运算符: a +=1

 6.逻辑运算符:and or  not   是与非

 7.成员运算符:in    not in    

 

 

    

  

 

posted @ 2019-11-02 17:09  躺云飘  阅读(193)  评论(0编辑  收藏  举报