2.3 变量
greeting = "HelloWorld" print(greeting) student_score = 0.0 print(student_score) y = 20 print(y) y = True print(y)
2.4 语句
greeting = "HelloWorld" print(greeting) student_score = 0.0 ; #语句结束时可以加分号(;),但不符合Python编程规范 print(student_score) a = b = c = 10 #链式赋值语句可以同时给多个变量赋值 print(a,b,c)
2.5 代码注释
#coding = utf-8 greeting = "HelloWorld" #这是一个整数变量 student_score = 0.0 print(student_score) #打印student_score变量
2.6模块
hello模块
#coding = utf-8 import world #导入world模块中的所有代码元素 from world import z #导入world模块中的变量z from world import x as x2 #导入模块中的变量x,并给它命名x2 x = 100 y = 20 print(y) #访问当前模块变量 print(world.y) #访问world模块变量y print(z) #访问world模块变量z print(x2) #x2是world模块别名
world导入模块
#coding = utf-8 #world模块 x = "你好" y = True z = 20.0



