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
| 比如我们需要让test.py在后台挂着,而不出现命令行窗口,那么可以使用以下命令: | |
| start /min python test.py | |
| linux下面: | |
| nohup python test.py & |
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
| 使用-encoding参数指明编码方式:javac -encoding UTF-8 XX.java |
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
| t = threading.Timer(timeout,conn.cancel) | |
| t.start() | |
| cursor = conn.cursor() | |
| cursor.execute(query) | |
| res = cursor.fetchall() | |
| t.cancel() |
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 org.apache.http.HttpHost; | |
| import org.apache.http.client.methods.CloseableHttpResponse; | |
| import org.apache.http.client.methods.HttpGet; | |
| import org.apache.http.client.protocol.HttpClientContext; | |
| import org.apache.http.config.Registry; | |
| import org.apache.http.config.RegistryBuilder; | |
| import org.apache.http.conn.DnsResolver; | |
| import org.apache.http.conn.socket.ConnectionSocketFactory; | |
| import org.apache.http.conn.socket.PlainConnectionSocketFactory; | |
| import org.apache.http.conn.ssl.SSLConnectionSocketFactory; |
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
| os.getenv('java') | |
| # or | |
| os.environ.get('java') |
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
| from time import sleep, time | |
| import sys, threading | |
| class KThread(threading.Thread): | |
| """A subclass of threading.Thread, with a kill() | |
| method. | |
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
| package cn.resolvewang; | |
| import com.sun.deploy.util.ArrayUtil; | |
| import java.lang.reflect.AccessibleObject; | |
| import java.lang.reflect.Field; | |
| import java.lang.reflect.Modifier; | |
| import java.util.ArrayList; | |
| import java.util.List; |
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 | |
| # -*- coding: utf-8 -*- | |
| import logging | |
| # create logger | |
| logger = logging.getLogger('simple_example') | |
| # Set default log level |
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/bin/env bash | |
| mkdir spider | |
| cd spider/ | |
| yum update -y | |
| # install pip on centos6 | |
| rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm | |
| yum install -y python-pip | |
| # install wget | |
| yum install -y wget |
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
| def to_dict(ins): | |
| table_columns = ins.__table__.c | |
| l = [column.key for column in table_columns] | |
| d = {} | |
| for k, v in ins.__dict__.items(): | |
| if k in l: | |
| d[k] = str(v) if v is not None else '' | |
| return d |
OlderNewer