随笔分类 -  Python

摘要:https://github.com/lavr/python-emails linux 发邮件可以使用mutt 阅读全文
posted @ 2018-04-27 14:16 raindream 阅读(236) 评论(0) 推荐(0)
摘要:#!/usr/bin/env python # -*- coding: utf-8 -*- if __name__ == '__main__': logname = './new_file.txt' with open(logname,'w') as logfile: with open('./5.txt', 'r') as f: fo... 阅读全文
posted @ 2018-04-26 19:49 raindream 阅读(208) 评论(0) 推荐(0)
摘要:#!/usr/bin/python #-*- coding:UTF-8 -*-#coding=utf-8 import requests import time import hashlib import sys def getUser(userId): aid = 0 t = time.time() aTime = int(round(t * 1000)) hl... 阅读全文
posted @ 2018-04-26 19:48 raindream 阅读(1431) 评论(0) 推荐(0)
摘要:stdin, stdout, stderr = client.exec_command('cd /home/someone;mkdir aa') def remote_modify(mblade): client = master_module.get_connection('remote_modi 阅读全文
posted @ 2016-03-06 17:08 raindream 阅读(184) 评论(0) 推荐(0)
摘要:1 import datetime 2 import time 3 4 d1 = datetime.datetime(2005, 2, 16) 5 d2 = datetime.datetime(2004, 12, 31) 6 tdelta = d1 - d2 7 print tdelta.secon 阅读全文
posted @ 2016-03-06 17:07 raindream 阅读(2834) 评论(0) 推荐(0)
摘要:常用的一些 1 import os 2 3 for d, cd, fl in os.wald('.'): 4 for f in fl: 5 sufix = os.path.splitext(f)[1][1:] 6 if sufix == 'py': 7 filename = os.path.join 阅读全文
posted @ 2016-03-06 17:07 raindream 阅读(143) 评论(0) 推荐(0)
摘要:使print既打印到终端,又写入文件 1 class Tee(object): 2 def __init__(self,*files): 3 self.files = files 4 def write(self,obj): 5 for f in self.files: 6 f.write(obj) 阅读全文
posted @ 2016-03-06 17:07 raindream 阅读(466) 评论(0) 推荐(0)
摘要:1. dir() 不带参数时,返回当前范围内的变量、方法和定义的类型列表;带参数时,返回参数的属性、方法列表。如果参数包含方法__dir__(),该方法将被调用。如果参数不包含__dir__(),该方法将最大限度地收集参数信息。 2. help() help()函数是查看函数或模块用途的详细说明,如 阅读全文
posted @ 2016-03-06 17:07 raindream 阅读(178) 评论(0) 推荐(0)
摘要:基本 import paramiko blade = '192.168.0.10' port = 22 username = 'admin' password = '100' localpath = '/home/local/test.txt' remotepath = '/home/remote/ 阅读全文
posted @ 2016-03-06 17:06 raindream 阅读(219) 评论(0) 推荐(0)
摘要:基本 1 import unittest 2 3 class OneTest(unittest.TestCase): 4 5 def setUp(self): 6 self.verificationErrors = [] 7 self.accept_next_alert = True 8 pass 阅读全文
posted @ 2016-03-06 17:06 raindream 阅读(986) 评论(0) 推荐(0)
摘要:基本 from selenium import webdriver import re driver = webdriver.Firefox() driver.get('https://www.google.com') main_window = driver.current_window_hand 阅读全文
posted @ 2016-03-06 17:06 raindream 阅读(194) 评论(0) 推荐(0)