随笔分类 -  python语法、模块

摘要:#基础用法 ##1.当天日期和时间 import datetime print(datetime.datetime.now()) print(datetime.date.today()) #高级实例 ##1.将字符串的时间转换为时间戳 方法: a = "2013-10-10 23:40:00" 将其 阅读全文
posted @ 2021-01-20 09:53 名字很长容易被惦记 阅读(220) 评论(0) 推荐(0)
摘要:##测试代码 from helium import * home_url = r'https://www.163.com/' driver = start_chrome(home_url) wait_until(Text("网易").exists) username = r'18601936599@ 阅读全文
posted @ 2020-12-20 19:09 名字很长容易被惦记 阅读(243) 评论(0) 推荐(0)
摘要:##进度条 import tkinter as tk import time # 创建主窗口 window = tk.Tk() window.title('进度条') window.geometry('630x150') # 设置下载进度条 tk.Label(window, text='下载进度:' 阅读全文
posted @ 2020-12-12 22:55 名字很长容易被惦记 阅读(190) 评论(0) 推荐(0)
摘要:#获取元素 ##1.获取当前页面的Url函数 方法:current_url 实例: driver.current_url ##2.获取元素坐标 方法:location 解释:首先查找到你要获取元素的,然后调用location方法 实例: driver.find_element_by_xpath("/ 阅读全文
posted @ 2020-12-09 09:45 名字很长容易被惦记 阅读(1620) 评论(0) 推荐(0)
摘要:API: http://python-docx.readthedocs.io/en/latest/#api-documentation ##1.将doc转为docx python3.8中win32com 要安装pypiwin32 pip install pypiwin32 from win32com 阅读全文
posted @ 2020-10-13 10:00 名字很长容易被惦记 阅读(4402) 评论(0) 推荐(0)
摘要:#cron定时任务 # coding=utf-8 """ Demonstrates how to use the background scheduler to schedule a job that executes on 3 second intervals. """ from datetime 阅读全文
posted @ 2020-08-28 21:18 名字很长容易被惦记 阅读(2287) 评论(0) 推荐(0)
摘要:#!/bin/env python import paramiko #设置日志记录 paramiko.util.log_to_file('/tmp/test') #建立连接 ssh=paramiko.SSHClient() #缺失host_knows时的处理方法 ssh.load_system_ho 阅读全文
posted @ 2020-08-26 21:23 名字很长容易被惦记 阅读(165) 评论(0) 推荐(0)
摘要:# -*- coding: utf-8 -*- #python operate mysql database import MySQLdb #数据库名称 DATABASE_NAME = '' #host = 'localhost' or '172.0.0.1' HOST = '' #端口号 PORT 阅读全文
posted @ 2020-08-26 21:22 名字很长容易被惦记 阅读(176) 评论(0) 推荐(0)
摘要:#!/usr/bin/env python import pymongo import datetime import random #创建连接 conn = pymongo.Connection('10.11.1.70',27017) #连接数据库 db = conn.study #db = co 阅读全文
posted @ 2020-08-26 21:21 名字很长容易被惦记 阅读(135) 评论(0) 推荐(0)
摘要:#通过管道传递 cat somefile.txt |python somescriot.py |sort import sys text = sys.stdin.read() #标准输入流 words = text.split() print words #用户互动 raw_input() x = 阅读全文
posted @ 2020-08-26 21:16 名字很长容易被惦记 阅读(544) 评论(0) 推荐(0)
摘要:#!/bin/env python # -*- coding: UTF-8 -*- #主动诱发异常 raise Exception('我创建的异常') #raise Exception('我创建的异常') #自定义异常 class SomeCustomException(Exception): pa 阅读全文
posted @ 2020-08-26 21:00 名字很长容易被惦记 阅读(142) 评论(0) 推荐(0)
摘要:#!/usr/bin/env python # -*- coding: utf-8 -*- import sys import time import socket def check(ip, port): print 'checking %s:%d .....' % (ip, port), soc 阅读全文
posted @ 2020-08-26 20:58 名字很长容易被惦记 阅读(156) 评论(0) 推荐(0)
摘要:#!/bin/env python #-*- encoding:utf-8 -*- #该测试没有详细的划分区间,只测试1到xx的全部IP范围 import time,os start_Time=int(time.time()) #记录开始时间 def init(): global ip_count 阅读全文
posted @ 2020-08-26 20:57 名字很长容易被惦记 阅读(254) 评论(0) 推荐(0)
摘要:#一、需要用到的库: ##1.操作xls格式的表格文件 读取:xlrd 写入:xlwt 修改(追加写入):xlutils ##2.操作xlsx格式的表格文件 读取/写入:openpyxl #二、实现代码 ##1.操作xls格式的表格文件 # coding=UTF-8 import xlrd impo 阅读全文
posted @ 2020-08-25 20:44 名字很长容易被惦记 阅读(401) 评论(0) 推荐(1)
摘要:#函数装饰器 1、简单装饰器 def my_decorator(func): def wrapper(): print('wrapper of decorator') func() return wrapper def greet(): print('hello world') greet = my 阅读全文
posted @ 2020-08-23 21:32 名字很长容易被惦记 阅读(792) 评论(0) 推荐(0)
摘要:#五种压缩文件对比 python压缩包操作依赖于本地的解压缩软件,所以不要指望rar工具会解压zip文件,反之亦然。 以下列出五种压缩文件 | 类型 | 模块 | 说明 | | | | | | gz | gizp | 通常仅仅能压缩一个文件。与tar结合起来就能够实现先打包,再压缩。 | | tar 阅读全文
posted @ 2020-07-29 14:48 名字很长容易被惦记 阅读(3643) 评论(0) 推荐(0)
摘要:官方文档 阅读全文
posted @ 2020-07-29 13:30 名字很长容易被惦记 阅读(145) 评论(0) 推荐(0)
摘要:#list 一、列表(可变序列) 1、常用的列表对象方法 方法 说明 lst.append(x) 将元素x添加至列表lst尾部 lst.extend(L) 将列表L中所有元素添加至列表lst尾部 lst.insert(index,x) 在列表lst指定位置index处添加元素x,该位置后面所有元素后 阅读全文
posted @ 2020-07-29 11:46 名字很长容易被惦记 阅读(927) 评论(0) 推荐(0)
摘要:ConfigParser解析的配置文件的格式为.ini的配置文件格式,就是文件中由多个section构成,每个section下又有多个配置项。 在程序中,使用ConfigParser.get(section,name)读取具体section下的配置内容。 confi.ini [HOST] HOST1 阅读全文
posted @ 2020-07-28 11:18 名字很长容易被惦记 阅读(148) 评论(0) 推荐(0)
摘要:使用文档 # -*- coding:utf-8 -*- #! python2 import shutil a=0 readDir = r"D:\pycharm-project\my-project\test\thefile2018-11-27.sh" writeDir = r"D:\pycharm- 阅读全文
posted @ 2020-07-28 11:17 名字很长容易被惦记 阅读(116) 评论(0) 推荐(0)