随笔分类 - Python
摘要:#### 列表推导式 #!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2020/11/22 14:34 # @Author : XiaoWei # @Email : 1464819144@qq.com # @FileName : 推导式.py
阅读全文
摘要:# ## 闭包函数 """ 概念: 内函数使用了外函数的局部变量 并且外函数把内函数返回出来的过程,叫做闭包 这个内函数叫做闭包函数 """ # 示例 # 1、基本语法 def func_1(): father = "100" def func_2(): print("这辆汽车的造价是: {}万元.
阅读全文
摘要:# -*- coding:utf-8 -*- i = 1 while i <= 9: j = 1 while j <= i: print("{:d}*{:d}={:2d}".format(j, i, i * j), end=' ') j += 1 print() i += 1 print('-' *
阅读全文
摘要:1、使用Exception try: 异常代码 except Exception as e: print(e) 2、使用 traceback模块(小编推荐使用此种方法,显示错误比较详细) import traceback try: 异常代码 except: traceback.print_exc()
阅读全文
摘要:python版本为:2.7 # -*- coding: utf-8 *-* import os,time,shutil,datetime def rmdir(deldir,N): dellist=os.listdir(deldir) deldate= datetime.timedelta(days=
阅读全文

浙公网安备 33010602011771号