Python学习--数据类型

来源:互联网 发布:nba2kol软件 编辑:程序博客网 时间:2024/05/16 05:33
#!/usr/bin/python# -*- coding: utf-8 -*-# Filename dataType.py# Python有四种类型的数# 1.整型a = 2print a# 2.长整型b = 123456789print b# 3.浮点数c = 3.2E2print c# 4.复数 复数为实数的推广,它使任一多项式都有根。复数当中有个“虚数单位”j,它是-1的一个平方根。任一复数都可表达为x+yj,其中x及y皆为实数,分别称为复数之“实部”和“虚部”。d = (2+3j)print d# 字符串,单双引号是一个意思e = 'hello world'print ef = "hello world"print f# 三引号引用多行字符串g = '''My name is python'''print g# 转义符h = 'what\'s your name?'print h# 行末加\表示继续显示下一行,不换行i = 'this is a ap\ple'print i# 字符串链接j = 'hello' ' world'print j# 使用逗号会让换行变为空格l = 'hello'm = 'world'print l,print m

  • 第二行是定义字符编码为utf-8,不然不能添加中文注释。
  • Python中变量名必须以字母或者下划线开始,变量名只能包括大小写字母,数字,下划线。
  • 变量名是大小写敏感的,a和A不是一个变量。
  • 代码执行结果:
2
123456789
320.0
(2+3j)
hello world
hello world
My name is 
python
what's your name?
this is a apple
hello world
hello world

原创粉丝点击