在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/ Python問答
獨特范 回答

誰告訴你字符串可以直接用dict()轉(zhuǎn)換為字典的?

念舊 回答

已經(jīng)解決了 缺少mysqlclient

pip install mysqlclient

久舊酒 回答

用pd.concat([df1,df2],axis=1,join='inner'),取并集圖片描述

遺莣 回答

url > 1024 這個問題怎么說呢,確實有點保守了,我已經(jīng)把源代碼hack 了,所以不存在這個問題,一般瀏覽器都是支持到2048長度

傻叼 回答

并不是200就一定代表成功,目測這應(yīng)該是豆瓣的一個默認(rèn)攔截頁面,可能判斷到你的請求非法,然后自動跳轉(zhuǎn)到一個默認(rèn)頁面了。

寫榮 回答

已解決:

import threading

import time

def test1():
    while True:
        print '111111111111'
        time.sleep(2)

def test2():
    while True:
        print '22222222222'
        time.sleep(10)
        print '222222222222end'
        break
    return

def test3():
    thread_list_all = threading.enumerate()
    while True:
        thread_list1 = threading.enumerate()
        thread_list_number = len(thread_list1)
        if thread_list_number < 4:
            dead_thread = list(set(thread_list_all).difference(set(thread_list1)))
            for item_thread in dead_thread:
                fun_name = item_thread.getName()
                if fun_name == 'test1':
                    t1 = threading.Thread(target=test1,name='test1')
                    t1.start()
                    t1.join()
                elif fun_name == 'test2':
                    t2 = threading.Thread(target=test2,name='test2')
                    t2.start()
                    t2.join()
        time.sleep(1)

t1 = threading.Thread(target=test1,name='test1')
t2 = threading.Thread(target=test2,name='test2')

while True:
    if t1.isAlive() is False:
        t1 = threading.Thread(target=test1,name='test1')
        t1.start()
        # t1.join()
    if t2.isAlive() is False:
        t2 = threading.Thread(target=test2,name='test2')
        t2.start()
        # t2.join()
安若晴 回答

strip()的參數(shù)不支持正則表達(dá)式,參數(shù)是字符序列,字符串收尾包含在那個序列里的就刪除,舉個例子:
In [1]: se = "+dwjsdd"
In [2]: se
Out[2]: '\+dwjsd\d'
In [3]: se.strip("d+")
Out[3]: 'wjs'

清夢 回答

proc = subprocess.Popen(args,shell=True,stdout=open(outimploc, 'w'), stderr=open(outimplocerr,'w'),stdin = subprocess.PIPE, cwd=self.tranusConf.workingDirectory).communicate()

原來要這樣處理,不會報錯winerror 6

import subprocess
from Action.SYS.get import *
from Action.SYS.Log import *
from Action.File.FileEvent import *
import os
class System:
    __get=None
    __OS=''
    __file=None
    def __init__(self):
        self.__get=get()
        self.__OS=self.__get.getOS()
        self.__file=FileEvent()

    def serverListenByPort(self,address, port, netstatus="ESTABLISHED"):
        result = []
        statuspos=0
        if self.__OS=='Linux':
            subp = subprocess.Popen('netstat -ano | grep %s:%s' % (address, port),  stdout=subprocess.PIPE)
            statuspos=5
            while True:
                buff = subp.stdout.readline()
                buff = str(buff, encoding='utf-8')
                buffers = buff.split()
                try:
                    if str(buffers[statuspos]).strip() == netstatus:
                        buffers.append(self.__OS)
                        result.append(buffers)
                except Exception as e:
                    pass
                if buff == '' or buff == None:
                    break;
        if self.__OS=='Windows':
            try:
                outimploc = self.__file.get_dir() + '/out.txt';
                outimplocerr = self.__file.get_dir() + '/error.txt';
                tranusConf = self.__file.get_dir()
                subp = subprocess.Popen('netstat -ano', stdout=open(outimploc, 'w'), stderr=open(outimplocerr, 'w'),stdin=subprocess.PIPE, cwd=tranusConf).communicate()
                statuspos = 3
                try:
                    f = open(outimploc, 'r')
                    while True:
                        line=''
                        try:
                            line = f.readline()
                            linsplit = str(line).strip().split()
                            if linsplit[1].strip() == '%s:%s' % (str(address).strip(),str(port).strip()):
                                if linsplit[3].strip()==netstatus:
                                    linsplit.append(self.__OS)
                                    result.append(linsplit)
                        except Exception as e:
                            Log.log('error', str(e))
                        if line == '' or line == None:
                            break;
                    f.close()
                except Exception as e:
                    Log.log('error', str(e))
            except Exception as e:
                Log.log('error',str(e))
        return result
我以為 回答

你可能需要先去一個醫(yī)學(xué)庫,把所有的疾病名稱都獲取到。然后用疾病名稱去搜索。

下墜 回答

python 有全局解釋鎖(GIL),出現(xiàn)這現(xiàn)象是應(yīng)該的。如果希望同時執(zhí)行,需要用多進(jìn)程模塊(multiprocess)

北城荒 回答

首先回答你的問題:程序主進(jìn)程退出之后,其子進(jìn)程或子線程都會終止。

在簡單說下你上面的例子的線程:
1,os.fork是個比較特殊的方法,一般函數(shù)都是一次調(diào)用一次返回,但是它不同,它是一次調(diào)用兩次返回(一次在主進(jìn)程一次在子進(jìn)程),所以你看到print('main')執(zhí)行之后,其實主進(jìn)程還沒有退出(可以將sleep時間加大,然后通過ps命令查看);
2,第二個例子就很好的說明了:程序主進(jìn)程退出之后,其子進(jìn)程或子線程都會終止。

抱緊我 回答

上代碼:

地址池創(chuàng)建

class Mysql(object):
    __instance = None

    def __new__(cls, *args, **kwargs):
        if cls.__instance is None:
            cls.__instance = super(Mysql, cls).__new__(cls, *args, **kwargs)
        return cls.__instance

    def __init__(self):
        self.mysql = PooledDB(creator=pymysql, mincached=10, maxcached=20,
                              host='127.0.0.1', port=3306, user='chinamap', passwd='p-0p-0p-0',
                              db='operation', charset="utf8")

    def getAll(self, sql):
        print(id(self.mysql))
        _conn = self.mysql.connection()
        _cursor = _conn.cursor()
        _cursor.execute(sql)
        result = _cursor.fetchall()
        _cursor.close()
        _conn.close()
        return result

另外兩個 引用的代碼

from tt4 import Mysql
import time
mysql = Mysql()
print(id(mysql))
ssql= "select * from tz_ioip"
while True:
    result = mysql.getAll(ssql)
    print(result)
    time.sleep(5)

圖片描述
圖片描述

玩控 回答

傳入可變參數(shù)時,用 PyTuple_Size() 獲取參數(shù)個數(shù),然后用 PyTuple_GetItem() 循環(huán)讀取每個參數(shù)值,最后根據(jù)情況轉(zhuǎn)換參數(shù)值。

請參考下面的代碼

/*
此 python 擴展示例代碼,計算整數(shù)數(shù)組和,如下:
    from liyi import psum
    psum(1, 2)
    psum(10, 20, 30)
    try:
        psum('a', 1)
    except TypeError:
        pass


## 編譯命令(以 linux 為例)
cc -g -Wall `python3.6-config --cflags` -o demo demo.c  `python3.6-config --ldflags`


## 參考
https://docs.python.org/3/c-api/index.html
 */
#include <Python.h>


// 計算整數(shù)數(shù)組和
static PyObject* psum(PyObject *self, PyObject *args)
{
    int sum = 0;
    for (int i=0; i<PyTuple_Size(args); i++) {
        PyObject *item = PyTuple_GetItem(args, i);
        // 數(shù)組元素必須是整型
        if (!PyLong_Check(item)) {
            char message[128];
            snprintf(message, sizeof(message), "%d-th item must be long", i);
            PyErr_SetString(PyExc_TypeError, message);
            return NULL;
        }
        sum += PyLong_AsLong(item);
    }
    return PyLong_FromLong(sum);
}

static PyMethodDef Methods[] = {
    {"psum", psum, METH_VARARGS, "Return sum of integer array"},
    {NULL, NULL, 0, NULL}
};

static PyModuleDef Module = {
    PyModuleDef_HEAD_INIT,
    "liyi", NULL, -1, Methods,
    NULL, NULL, NULL, NULL
};

static PyObject* PyInit(void)
{
    return PyModule_Create(&Module);
}

int main(int argc, char *argv[])
{
    PyImport_AppendInittab("liyi", &PyInit);

    Py_Initialize();
    PyRun_SimpleString(
        "from liyi import psum\n"
        "for numbers in [(1,2), (10,20,30)]:\n"
        "    print('%s = %d' % ('+'.join(map(str, numbers)), psum(*numbers)))\n"
        "try:\n"
        "    psum('a', 1)\n"
        "except TypeError:\n"
        "    import traceback; traceback.print_exc()\n"
    );
    if (Py_FinalizeEx() < 0) {
        exit(1);
    }
    return 0;
}
傲嬌范 回答

你這已經(jīng)是線性時間復(fù)雜度了,再低的話除非是對數(shù)時間

朽鹿 回答

這有啥需要遞歸的, 一個for 加個if 判斷不就完事了。。。 或者你的想法沒有表達(dá)清楚?

字典取值
···python
for i in list:

if i["isEnd"] == no:
    request
else:
    break

···

傲寒 回答

mysqldump備份腳本加個參數(shù) --single-transaction

她愚我 回答

感謝β_3000的啟發(fā),原來好多東西在紙上畫畫就會清楚很多。

a = arange(12).reshape(3,4)
i = array( [ [0,1],    
             [1,2] ] )
j = array( [ [2,1], 
             [3,3] ] )
print(a[i])             
print(a[i,j])   

a是一個二維數(shù)組,用二維數(shù)組i索引后竟然變成一個三維數(shù)組,如圖:
那么a[i,j]就是在a[i]上再按j索引一次?我不知道對不對,至少從結(jié)果上看是對了。
圖片描述

遺莣 回答

外鍵在mysql系統(tǒng)里只是一個邏輯結(jié)構(gòu)定義,為了性能考慮,mysql會自動為每個外鍵創(chuàng)建一個索引結(jié)構(gòu)段,而你定義了兩個外鍵,其中有一個已經(jīng)是主鍵或者某個索引的組成部分,并且滿足最左匹配原則,所以只會為你創(chuàng)建另外一個外鍵的索引