栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

看漫画学Python 第二章代码

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

看漫画学Python 第二章代码

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

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/767100.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号