赞
踩
ctr + / - 添加/取消注释
ctr + s - 保存
ctr + c - 复制
ctr + v - 粘贴
ctr + x - 剪切
ctr + a - 全选
ctr + z - 撤销
ctr + shift + z - 反撤销
为程序添加注释可以用来解释程序某些部分的作用和功能,提高程序的可读性。主要分为单行注释与多行注释。
单行注释使用 “ # ”
# print('helloworld')
多行注释使用 ‘’‘注释内容’’’ 或者 “”“注释内容”""
a = 10
print(a)
需严格遵循缩进原则,一般情况下,一行中只存在一条语句
Python中数有四种类型:证书、长整数、浮点数和复数。
2)文本数据 - 用文字来提供数据的数据,例如:姓名、公司名、学校名、家庭住址、商品名称等。
文本对应的类型:str(字符串)
3)布尔数据 - 在程序中用True表示肯定、真,用False表示否定、假的数据就是布尔
布尔对应的类型:bool(布尔)
4) 其他常用数据类型:list(列表)、dict(字典)、tuple(元组)、set(集合)、迭代器、生成器、function(函数)、自定义类型等。
获取数据类型的方式 - type
print(type(10)) # <class 'int'>
print(type(True)) # <class 'bool'>
print(type('')) # <class 'str'>
# 类型转换
# 类型名(数据) - 将指定数据转换成指定类型
# 3.14 -> 3
print(int(3.14)) # 3
print(float(8)) # 8.0
print(int(True)) # 1
print(int(False)) # 0
# print(int('abc')) # 报错
print(int('123'))
print(float('
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。