python3第一课

我的第一个python程序;

  print(“你好”)

print是输出

python3的基础语法;

  标识符

    1. 第一个字符必须是字母中的字母或下划线“_”。

    2. 标识符的其他的部分有字母、数字和下划线组成。

    3.标识符对大小写敏感。

python里的的一些保留字、关键字不能用。这个和JS里的一样

   如:'False’, 'None', 'True', 'and’, 'as', assert', 'break', 'class', 'contiue', 'def', 'elif', 'else', 'except', finally', 'for', 

      'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'rise', 'return', 'try', 'while', 'with', 'yield',\

python里的注释;

  # print(“你好”)

  python的注释是,  单行:#    多行:,,,    ,,,             

  HTMLLI的注释是<!--  -->    

  CSS是注释是/*  */  

  script的注释是,单行是 //   多行是/*  */

行与缩进是python里的一个特色,他不需要大括号{},用空格缩进就可以,

   如:if  1:

                 print("ok")

           else:

                 print("no")

    如:错误

           if   1:

                 print("ok")

          else:

             print("no")   不对齐就会报错

python里还有很多的特色

     如: a, b, c = 3, 4, 5.5     同时给多个对象指定多个变量

              a = b = c = 1       可以同时为多个变量赋值

python中有6个标准的数据类型:

   number (数字), string (字符串), list(列表), tuple(元组), sets(集合), dictionary(字典)

   number支持:int, float,   bool,    complex(复数)

   type()函数可以用来查询变量所指对象类型

  如:a, b, c, d = 3, 5.5, true, 4+3j

          print(type(a),type(b),type(c),type(d))

          <class 'int'><class 'float'><class 'bool'><class 'complex'>


  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值