- 编程语言
- Python特点
- 应用领域
- 数据类型与运算
- 简单使用
- 编程语言
- 编程语言的分类:根据运行方式(强类型与弱类型) 编译运行:源代码 --> 编译器 (编译)--> 程序文件; 解释运行:源代码 --> 运行时启动解释器,由解释器边解释边运行;
- 编程模型:过程式编程语言,面向对象的编程语言 程序=指令+数据 过程式:以指令为中心来组织代码,数据是服务于代码;
顺序执行 选择执行 循环执行 代表:C,bash
对象式:以数据为中心来组织代码,围绕数据来组织指令;
类(class):实例化对象,method; 代表:Java, C++, Python
-
python即是编译器又是解释器,严格区分字符大小写、格式
-
Python特点 简单易学-->开发效率高-->典型工具语言-->强大丰富的模块库-->优秀跨平台
-
应用领域
- 数据采集与处理
- 数据计算与分析
- 人工智能与机器学习
- 自动化测试
- 系统集成运维(ssh/ansible/fabric)
- web互联网
-
数据类型与运算
- java常用数据类型
整型:int、byte、shot、long
非整型:double、float
boolean:true、false
字符型:char,
- Python数据类型:Python将所有数据存为内存对象,变量事实上指向内存对象的引用
number:数字类型 int,float,bool,fractions,complex string:字符串,无单独字符,引号必须 list:列表 Tuple:元组 set:集合 dictionary:字典 什么样的类型决定能够参与的运算!
- 运算
+-* / % = += -= %=
![](https://s1.51cto.com/images/blog/201903/28/b0d0441569b0483ca45fbca6f713990c.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=)
- 简单使用
'''abc''' 、 """abc""" 三引号支持换行操作(enter)
>>> str1='''abc
... ef
... gdg'''
>>> str1
'abc\nef\ngdg'
字符也支持运算,+ 连接 *出现次数
>>> a='abc'
>>> b='sfw'
>>> a+b
'abcsfw'
>>> a*3
'abcabcabc'
多行编写内容,规范美观或单行比较长:+\表示
eg:total='item_one'+\
'item_two'+\
'item_three'
输出内容为:item_oneitem_twoitem_three
#judging var type
a = 'hello world'
b = 12345
c = 1.2345
aa = type(a);bb=type(b);cc=type(c)
print('%s is %s\n%s is %s\n%s is %s' %(a,aa,b,bb,c,cc))
# print('hello world is',type('hello world'))
#input from stin
print('please introduce youself,what\'s u name?')
name=input('please introduce youself,what\'s u name?')
# print('please input your password')
passwd=input('please input your password:')
# print('your age:')
age=int(input('your age:'))
print('successful ! your name is %s,password is %s,age=%d' %(name,passwd,age))