第1001次python入门——Day01

变量以及数据类型

# a 我们就称为变量,方便批量更改

a = '你好,世界'
print(a)

b = 34
print(b)

c = True
print(c)

# 数据类型的概念:数据都有各自类型

# 数字类型:整数 int  浮点 float  复数 complex
print(45)
print(3.1415926)
print((-1) ** 0.5)

# 字符串类型: 其实就是一段普通文字
# 使用一对单引号或双引号包裹
print('today 是 good day')
print("45")

# bool类型: 用来表示真假
# 只有两个值
print(3 > 4)
print(6 > 4)

# 列表类型:
names = ['Thorne', 'Shuai', 'Jiaxi', 'Javis']

# 字典类型:
person = {'name': 'Thorne', 'age': '18'}

# 元组类型:
nums = (1, 2, 3, 4, 5)

# 集合类型
x = {9, 'hello', 'hi', True}

查看数据类型

a = 34
b = 'cool'
c = True
d = ['Thorne', 'zhaoshuai', 'jiaxi']
x = {9, 'hello', 'hi', True}
# 使用type内置类可以查看变量对应的数据类型
print(type(a))
print(type(b))
print(type(c))
print(type(d))
print(type(x))
print(type(3.14))
print(type(4))
print(type('hello'))

# Python里面的变量是没有数据类型的,我们所说的是变量对应的值的数据类型

标识符和关键字

# 标识符:变量,模块名,函数名,类名
# 标识符的命名规则
# 规则:
# 1.由数字,字母,下划线组成,不能以数字开头
# 2.严格区分大小写
# 3. 不能使用关键字

# 变量实际上是赋值运算语句
a = 23

a_b = 'hello'
print(a_b)

输出语句

# Python使用print内置函数来输出内容

# print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
# sep 默认分隔符为' '
# end 执行完print后,默认以'\n'换行
# file 默认输出位置
# flush

print('Hello', 'ni', 'hao', sep='+', end='.......')
print('hello')

输入语句

# python里面用input内置函数
# input()

# 变量保存的结果都是字符串
password = input('输入:')
print(type(password))

猜你喜欢

转载自blog.csdn.net/Thorne_lu/article/details/113286042
今日推荐