Python基本语法

1-     """  或  '''   来指定多行字符串

example:

      s='''this is a multi-line string.

     This is the second line'''

print:

      this is a multi-line string.

      This is the second line

2- 从其他信息中构建字符串,format()

example:

      age    =    20

      name    =    'Swaroop'

      print('{0}    was    {1}    years    old    when    he    wrote    this    book'.format(name,    age))

print:

       Swaroop was 20  years old when he wrote this book

3-转义字符

     \   指定单引号:     'What\'s    your name?'

     \\        来指定反斜杠本身

     r    或  R  来指定一个原始(Raw)字符串:     '\\1'   和    r'\1'   输出的结果相同

4-for循环

      for   i   in    range(1,    5):
                print(i)

print:

      1

      2

      3

      4     

5- 函数:

       用 def 来定义函数

       def    say_hello():
                #    该块属于这一函数
                print('hello    world')
       #    函数结束
       say_hello()        #    调用函数

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值