随笔分类 - 编程语言 / python
摘要:迭代器 1.for 表达式 >>> [x for x in range(10)] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> [(x,x-1) for x in range(10) if x%2==0] [(0, -1), (2, 1), (4, 3), (6, 5), (
阅读全文
摘要:# python 类支持封装、继承、多态 # 类名称首字符大写。建议遵循驼峰语法 # 第一行代码,定义一个空类 class FirstClass(object): pass # 类变量和 类方法 class SecondClass(object): name='张三' age=30 def intr
阅读全文
摘要:import os,threading,requests ip=input('请输入要检测的ip:').strip().split('.')[0:3] ip='.'.join(ip) def detect(i): address=ip+'.%s'%i if os.name == 'nt': res=
阅读全文
摘要:https://raw.githubusercontent.com/zhiwehu/Python-programming-exercises/master/100%2B%20Python%20challenging%20programming%20exercises.txt 100+ Python
阅读全文
摘要:import cv2 as cv import sys import time # 指定视屏存储解码格式 fourcc = cv.VideoWriter_fourcc(*'XVID') out = cv.VideoWriter('out.avi', fourcc, 20.0, (640, 480))
阅读全文
摘要:import pymysql connect=pymysql.connect(host="172.7.200.2",port=3306,user="root",passwd="123",db="mysql",charset="utf8") cursor=connect.cursor(pymysql.
阅读全文
摘要:import smtplib from email.mime.text import MIMEText from email.utils import formataddr # msg =MIMEText('正文:来自python的邮件','plain','utf-8') msg['From'] =
阅读全文
摘要:import threading import queue import os q= queue.Queue() for i in range(1,255): q.put(i) try: f = open('1.txt','a') def fun01(num): result=os.popen('p
阅读全文
摘要:#!/usr/bin/python # -*- coding: UTF-8 -*- import calendar cal = calendar.month(2016, 1) print "以下输出2016年1月份的日历:" print cal
阅读全文
摘要:import re re.findall() 查询到所有符合的 re.search re.match re.compile flags 修改正则的匹配规则 特殊符号 "." 除换行符外的任意字符 "^" 匹配开头 "$" 匹配结尾 "*" 重复前一个字符0或尽可能多次 "+" 重复前一个字符1或尽可
阅读全文
摘要:import logging https://www.cnblogs.com/yuanchenqi/articles/5732581.html https://www.cnblogs.com/qianyuliang/articles/7234217.html#top import logging #
阅读全文
摘要:import hashlib >>> ob=hashlib.md5(b'123') >>> ob.update(b'123') >>> ob.hexdigest() '4297f44b13955235245b2497399d7a93'
阅读全文
摘要:import sys sys.argv[0] sys.stdin.readline() sys.stdout.write() sys.stderr sys.exit() getdefaultencoding() sys.path ==>echo $PATH sys.platform ==>平台信息w
阅读全文
摘要:import os os.name ==>uname os.getcwd() ==>pwd os.chdir() ==>cd os.mkdir() ==>mkdir os.makedirs() ==>mkdir -p os.removedirs() ==>rmdir 只能删除空文件 os.listd
阅读全文
摘要:目录安装python3常用库 安装python3 安装python3.6(更高版本对openssl版本有要求centos7可能build失败) curl -q# https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tar.xz -o Python
阅读全文