This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
sys.path.append('/foo/bar') | |
# sys.path 是一个列表, 导入模块时,从这些地方寻找。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf8 | |
from enum import Enum | |
class Color(Enum): | |
red=1 | |
green=2 | |
black=3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf8 | |
from collections import OrderedDict | |
d = {'banana': 3, 'apple': 4, 'pear': 1, 'orange': 2} | |
for k,v in d.items(): | |
print(k,v) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 from logging import * | |
4 import logging.handlers | |
5 | |
6 | |
7 logFormat = '%(asctime)s - %(name)s - %(levelname)s - %(funcName)s:%(lineno)d -%(message)s' | |
8 | |
9 filehandler = logging.handlers.TimedRotatingFileHandler(filename='somelogname', when='W0') | |
10 fmt = Formatter(logFormat) | |
11 filehandler.setFormatter(fmt) | |
12 logger = getLogger("inf") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/python | |
import urllib | |
import urllib2 | |
url = 'http://10.10.0.3:8080/openapi/client/downloadPlanid' | |
values = {'oauth_id':'lang', 'password':'123456'} | |
param = urllib.urlencode(values) | |
req = urllib2.Request(url, param) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/python | |
from urllib import urlopen | |
import re | |
import string | |
from datetime import * | |
import datetime | |
print 'Hello World' | |
p = re.compile('<td class="start" data-win-number=\'(.*?)\' data-period="(.*?)">(.*?)</td>') | |
themax=1 | |
timelist = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include "curl/curl.h" | |
using namespace std; | |
int main() | |
{ | |
CURL *_curl; | |
CURLcode _res; | |
const string urltmp("http://xxvity&usxxx=222"); | |
cout << urltmp << endl; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#grep "Got AppInfo by AppKey.*succeed" some.log | awk '{print $13}' > tmptest.key | |
while read dt | |
do | |
key=${dt##App*[} | |
key=${key%]} | |
echo $key | |
done < tmptest.key |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a=`ls -l` | |
echo $a | |
echo | |
echo "$a" | |
a=$(ls -l) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# 支持 定制路径指向 | |
# 支持 定制同目录内多文件处理 | |
# 支持 定制保存时间 | |
# 支持 指定删除旧数据的时间 | |
# 支持 每天定时touch 昨天每个小时日志 | |
# 支持 指定备份目录,并将2天以前的旧日志move到备份目录,如果指定目录为相对路径,那么相对的点则为 -P 所指定的目录 | |
# 支持 删除旧数据开关 | |
# 支持 支持2种日志备份方式,按小时,按天 |