码迷,mamicode.com
首页 > 编程语言 > 详细

Python的初步了解

时间:2018-11-30 22:32:35      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:while   pytho   区别   class   nic   区分   语言   str   print   

  Python是解析性语言,Python解释器将源程序解释并执行。

  基本语法  

  print()   --打印字符串

  -直接打印

print("hello world")

  结果:

  hello world

  -打印字符串变量

hello = ‘hello world‘
print(hello)

  结果:

  hello world

  -打印unicode编码

hello = ‘hello\u0020world‘
print(hello)

  结果:

  hello world

  Python根据对齐缩进来区分程序块

 代码一:

while count < 5:
    print(count)
    # count = 100
    count = count + 1

print(123)

 输出结果为: 

0
1
2
3
4
5

123

代码二:

count = 0
while count < 10:
    print(count)
    # count = 100
    count = count + 1

    print(123)

  输出结果为:

0
123
1
123
2
123
3
123
4
123
5
123

 代码一与代码二唯一的区别就是对齐不一样,导致的结果就截然不同,所以在使用python编程时必须注意代码缩进与对齐的问题。 

Python的初步了解

标签:while   pytho   区别   class   nic   区分   语言   str   print   

原文地址:https://www.cnblogs.com/10cm/p/10046717.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!