参考:1
注意:选择社区版
变量就是一个存储数据的时候当前数据所在的内存地址的名字
变量名自定义,要满足标识符命名规则
标识符命规则:
关键字:
# 定义变量,输出变量 my_name = "Pam" # 变量命名习惯:下划线 print(my_name) # 打印输出 my_Favourite = "Python" # 变量命名习惯:小驼峰 print(my_Favourite) # 打印输出
""" type(变量名) -- 用于检测数据类型 """ # int --整型 i = 1 print(type(i)) # float --浮点型 j = 1.2 print(type(j)) # bool --布尔值,有两个值:True和False q = True print(type(q)) # str --字符串 p = "hello world!" print(type(p)) # list --列表 a = [1,2,3] print(type(a)) # tuple --元组 b = (2,3,4) print(type(b)) # set --集合 c = {1,2,3} print(type(c)) # dict --字典 d = {"name":"Pam","age":"11"} print(type(d))
原文:https://www.cnblogs.com/pam-sh/p/12833601.html