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

Day1[下] - Python基础 基本语法、流程控制

时间:2017-05-21 16:49:27      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:变量   form   info   定义   not   block   oba   use   pos   

一、变量\字符编码

Variables are used to store information to be referenced and manipulated in a computer program. They also provide a way of labeling data with a descriptive name, so our programs can be understood more clearly by the reader and ourselves. It is helpful to think of variables as containers that hold information. Their sole purpose is to label and store data in memory. This data can then be used throughout your program.

变量定义的规则:

      • 变量名只能是 字母、数字或下划线的任意组合
      • 变量名的第一个字符不能是数字
      • 以下关键字不能声明为变量名
        [‘and‘, ‘as‘, ‘assert‘, ‘break‘, ‘class‘, ‘continue‘, ‘def‘, ‘del‘, ‘elif‘, ‘else‘, ‘except‘, ‘exec‘, ‘finally‘, ‘for‘, ‘from‘, ‘global‘, ‘if‘, ‘import‘, ‘in‘, ‘is‘, ‘lambda‘, ‘not‘, ‘or‘, ‘pass‘, ‘print‘, ‘raise‘, ‘return‘, ‘try‘, ‘while‘, ‘with‘, ‘yield‘]

变量的赋值:

name = ‘Tao Three‘
name2 = name

print(‘before:‘,name,name2)

name2 = ‘xiao Tao‘

print(‘after:‘,name,name2)

  

Day1[下] - Python基础 基本语法、流程控制

标签:变量   form   info   定义   not   block   oba   use   pos   

原文地址:http://www.cnblogs.com/crazytao/p/6885071.html

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