Python3 数据类型

数据类型有四种

  • 整数:如1
  • 长整数:如1324523453246,很大的数
  • 浮点数:带小数点的数, 如 1.123 3E-2
  • 复数:如 3 + 3j 1.21 + 5j

字符串

  • python中单引号和双引号使用时一样的
  • 指定多行字符串的时候使用 ”’ 或者 “”“
  • 字符串是不可变的
  • 和java一样, 当 “你”+“在”+“干嘛”等效于 “你在干嘛”
  • 自然字符串:在字符串的前面加上r 或 R, 如:r”this is main \n” 如果是unicode 编码,把r 或 R 换成 u 或 U

多行语句

  • 一般建议一行写完一条语句但是实在写不完,可以在末尾加吧反斜杠

aa = int + \
boolean + \
true

python保留字

['False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']

标识符

  • 字母,下划线, 数字组成,第一个字母必须是字母,下划线打头
  • 从3版本开始,非-ASCll 标识符也是可以的
  • 编码:从3开始源码文件已 UTF-8编码

输出语句

x = 12
y = 13
print(x)
print(y)
#不换行输出
print(x, end=" ")
print(y, end=" ")

猜你喜欢

转载自blog.csdn.net/qq_29291085/article/details/77689625