Python入门-学习总结

开发环境

官网下载:https://www.python.org/downloads/
  基础介绍:
  在这里插入图片描述
  在这里插入图片描述
  Python——python的命令行环境
  IDLE——简单的python shell环境,可以直接File->New File新建一个简单文本编辑环境,支持编辑、运行、调试等IDE基础功能。

基本语法

数据类型、条件控制、异常、函数、类、文件
  
  1、数据类型(数字、字符串、列表、元祖、字典、集合)
  
  a = 2
  
  str = “asdf” str =’asdf’ str [2] len(str ) str [2:4] str[2:4:2]
  
  list = [1,’sd’,3]
  list[2]#3
  list.append(‘asdf’) #[1,’sd’,3,’asdf’]
  list.insert(1,3) #[1,3,’sd’,3,’asdf’]
  list.remove(3)#[1,’sd’,3,’asdf’]
  
  tuple=(5,6,7)#无增删改,仅能查询
  tuple=(5,)#单元素时候要加上,否则会被识别为int
  type((5))#<class ‘int’>
  type((5,))#<class ‘tuple’>
  
  dict={1:2,3:4,’a’:3}
  dict[1]#2
  dict[3]=5#{1:2,3:5,’a’:3}
  dict[4]=6#{1:2,3:5,’a’:3,4:6}
  del dict[1]#{3:5,’a’:3,4:6}
  dict[0]#报错
  
  set={1,3,2,4,5}#{1,2,3,4,5}
  set={1,3,2,4,2,5}#{1,2,3,4,5}
  
  +、-、*、/、%取模、**幂值(3**2=9)、//取整除(9//2=4,-9//2=-5)
  
  
  2、条件控制
  if-elif-else、while、for xx in xx-s、for xx in range(1,10)
  没有++ – 操作符号,有+=、-=
  
  for i in range(1,10):
  print(i)
  print(‘\n\n’)
  
  
  3、异常
  try:
  xxxx
  except Excpetion as e:
  print(e)
  
  
  4、函数
  def func(a,b,c=5,*d):
   print(d)
   num=0
   for i in d
   num+=i
   return a+b
2+int(num/len(d))
  print(func(1,2,3,3,4,4))#11
  
  
  5、类
  class Cup():
   def init(self,a,b)
  class Cup_new(Cup):
   def init(self,a,b,c):
   super()._init(a,b)
  
  t=Cup_new()
  
  
  6、文件
  fout = open(path,mode)#mode=’r’/’w’
  for line in fout:
   print(line)
  fout.write(‘dddd\n’)
  fout.close()

python库

内置库、第三方库
  
  内置库:
  time(时间)
  os(操作系统)
  sys(环境传入变量)
  random(随机)
  re(正则)
  
  第三方库:
  Numpy(n纬数组)
  pandas(二维数据)
  matplotlib(数据可视化)
  nptk(自然语言处理)
  requests(爬虫)
  tenforflow(人工智能)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值