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

鍍金池/ 問(wèn)答

使用下面的 python 腳本,你可以輕松實(shí)現(xiàn)多開(kāi)

# -*- coding: utf-8 -*-
'''
同時(shí)運(yùn)行多個(gè)進(jìn)程,用法:
    python3 xx.py <進(jìn)程數(shù)量> <進(jìn)程啟動(dòng)參數(shù)>


@author: 李毅
'''
import asyncio
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter, REMAINDER


async def single(wid, cmd):
    p = await asyncio.create_subprocess_exec(*cmd)
    print('#{} pid={} 已經(jīng)啟動(dòng)'.format(wid, p.pid))
    await p.communicate()
    print('#{} pid={}, 代碼={} 已經(jīng)結(jié)束'.format(wid, p.pid, p.returncode))


async def main(loop, args):
    if not args.worker or not len(args.cmd):
        return
    ps = [single(i, args.cmd) for i in range(args.worker)]
    return await asyncio.gather(*ps)


if __name__ == '__main__':
    parser = ArgumentParser(formatter_class=ArgumentDefaultsHelpFormatter)
    parser.add_argument('worker', type=int, help='進(jìn)程數(shù)')
    parser.add_argument('cmd', nargs=REMAINDER, help='命令參數(shù),例如: "sleep 30"')
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main(loop, parser.parse_args()))

舉例:同時(shí)開(kāi)啟 10 個(gè) ping -c4 baidu.com 進(jìn)程

python3 a.py 3 ping -c4 baidu.com

輸出如下

PING baidu.com (123.125.115.110) 56(84) bytes of data.
#1 pid=137 已經(jīng)啟動(dòng)
#2 pid=138 已經(jīng)啟動(dòng)
#0 pid=139 已經(jīng)啟動(dòng)
PING baidu.com (220.181.57.216) 56(84) bytes of data.
PING baidu.com (123.125.115.110) 56(84) bytes of data.
64 bytes from 123.125.115.110 (123.125.115.110): icmp_seq=1 ttl=52 time=38.0 ms
64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=1 ttl=55 time=36.3 ms
64 bytes from 123.125.115.110 (123.125.115.110): icmp_seq=1 ttl=52 time=38.0 ms
64 bytes from 123.125.115.110 (123.125.115.110): icmp_seq=2 ttl=52 time=37.9 ms
64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=2 ttl=55 time=36.2 ms
64 bytes from 123.125.115.110 (123.125.115.110): icmp_seq=2 ttl=52 time=37.6 ms
64 bytes from 123.125.115.110 (123.125.115.110): icmp_seq=3 ttl=52 time=37.9 ms
64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=3 ttl=55 time=36.1 ms
64 bytes from 123.125.115.110 (123.125.115.110): icmp_seq=3 ttl=52 time=37.8 ms
64 bytes from 123.125.115.110 (123.125.115.110): icmp_seq=4 ttl=52 time=37.9 ms

--- baidu.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3002ms
rtt min/avg/max/mdev = 37.916/37.955/38.024/0.199 ms
64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=4 ttl=55 time=36.1 ms

--- baidu.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 36.113/36.218/36.374/0.254 ms
#1 pid=137, 代碼=0 已經(jīng)結(jié)束
#2 pid=138, 代碼=0 已經(jīng)結(jié)束
64 bytes from 123.125.115.110 (123.125.115.110): icmp_seq=4 ttl=52 time=37.7 ms

--- baidu.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 37.647/37.818/38.060/0.249 ms
#0 pid=139, 代碼=0 已經(jīng)結(jié)束
笨小蛋 回答

鑒于谷歌大佬去年好像搞了個(gè)去除水印大法On the Effectiveness of Visible Watermarks。個(gè)人認(rèn)為直接顯式添加水印方式保護(hù)性一般。

不知題主有沒(méi)有考慮用數(shù)字水印。這種水印的好處就是對(duì)原圖影響小,而且不容易被抹去,魯棒性強(qiáng)。

離殤 回答

雖然不建議直接在子組件直接修改父組件的數(shù)據(jù),但是你這個(gè)需求實(shí)現(xiàn)起來(lái)還挺簡(jiǎn)單的
1.

<li v-for="(item,index) in arr" @click=change(age[index])>{{item.name}}{{age[index]}}</li>

改成

<li v-for="(item,index) in arr" @click=change(index)>{{item.name}}{{age[index]}}</li>

2.

change(num){
    return num++; //這樣不行
}

改成

change(index) {
  this.age.splice(index, 1, this.age[index] + 1)
}
有你在 回答

debug一下看看哈,我也好奇。。。強(qiáng)勢(shì)關(guān)注

青黛色 回答

你else也要return getNum
另外 var num = num ? num : 1 最好寫成 function(ele,box,num = 1){}

默念 回答

pip 不支持 mysql-connector-python 了,編譯安裝

git clone https://github.com/mysql/mysql-connector-python.git
cd mysql-connector-python
python ./setup.py build
python ./setup.py install
離夢(mèng) 回答

本來(lái)這個(gè)界面是監(jiān)聽(tīng)window的滾動(dòng)條,你現(xiàn)在把他放在iframe標(biāo)簽里當(dāng)然不好用了。
你把iframe標(biāo)簽添加id,進(jìn)行監(jiān)聽(tīng)滾動(dòng)條

懷中人 回答

answer1: JS 中訪問(wèn)對(duì)象屬性有兩種方法

  • 使用 . 運(yùn)算符,其左邊是引用對(duì)象的變量名稱,右邊是屬性名稱(加引號(hào),加了引號(hào)叫字符串)
  • 使用 [] 運(yùn)算符,其左邊是引用對(duì)象的變量名稱(無(wú)引號(hào)),中間是一個(gè)表達(dá)式,其計(jì)算結(jié)果是表示屬性名稱的字符串。字符串本身也是一個(gè)表達(dá)式,所以可以直接給 g["id"],它與 g.id 效果等同

上面提到的“名稱”,其實(shí)叫做標(biāo)識(shí)符,在 JS 中,標(biāo)識(shí)符是有約束的,比如 your-name 就不是一個(gè)合法的標(biāo)識(shí)符,但是它卻是一個(gè)合法的屬性名(因?yàn)?JS 的對(duì)象可以看做一個(gè) Hash 表,所有字符串都中以做為鍵,卻屬性名),這種情況下需要引用屬性,必須使用 [] 運(yùn)算符。比如 o.your-name 就是錯(cuò)誤的,而 o["your-name"] 才是正確。

o.your-name 被會(huì)解釋器解釋為 o.your - name,是一個(gè)減法表達(dá)式。

answer2:根據(jù)上述原因,g.id.name 本身是一個(gè)合法的表達(dá)式,可以取到其值 1。但是我理解你這里是是想實(shí)現(xiàn)類似 lodash 中 _.get() 函數(shù)的功能,即給定一個(gè)字符串表示屬性路徑,要獲取其值,那么可以分解路徑,再通過(guò)循環(huán)來(lái)獲取值

function get(obj, attrPath) {
    const segments = attrPath.split(".");
    let current = obj;
    for (let i = 0; i < segments.length; i++) {
        current = current[segments[i]];
        // 容錯(cuò)處理,如果某一步取值為 null 或 undefined
        // 就不可能再繼續(xù)下去,直接返回該值即可。
        // 也可以根據(jù)業(yè)務(wù)邏輯需要在這里拋出異常
        if (current === void 0 || current === null) {
            return current;
        }
    }
    return current;
}

使用

get(g, "id.name")

cannot read property 'length' of undefined
cannot read property 'length' of undefined
cannot read property 'length' of undefined

不是不能識(shí)別length,是不能讀取undefined.length。所以是你要讀取的length的目標(biāo)對(duì)象本身不存在(或值為空)!

終相守 回答

問(wèn)題在format函數(shù)上,如果沒(méi)有指定小數(shù)點(diǎn)后面的精度,只用f,默認(rèn)是小數(shù)點(diǎn)后6位
圖片描述

大濕胸 回答

首先,你的 $config 數(shù)組中一定包含以下元素:

$config = [
    //others
    'modules' => [
        'debug' => [
            'class' => 'yii\debug\Module',
        ], 
        'gii'   => [
            'class' => 'yii\gii\Module',
        ];
    ],
    //others
]

這里說(shuō)明一下繼承關(guān)系:

class yii\base\Application extends yii\base\Module

class yii\base\Module extends yii\di\ServiceLocator

class yii\di\ServiceLocator extends yii\base\Component

class yii\base\Component extends yii\base\Object

  • yiibaseApplication::__construct() 方法注解
public function __construct($config = [])
{
    Yii::$app = $this;
    //將\yii\base\Application中的所有的屬性和方法交給Yii::$app->loadedModules數(shù)組中
    static::setInstance($this);

    $this->state = self::STATE_BEGIN;

    //加載配置文件的框架信息 如:設(shè)置別名,設(shè)置框架路徑等等最為重要的是給加載默認(rèn)組件
    $this->preInit($config);

    //加載配置文件中的異常組件
    $this->registerErrorHandler($config);

    // 調(diào)用父類的 __construct。
    // 由于Component類并沒(méi)有__construct函數(shù)
    // 這里實(shí)際調(diào)用的是 `yii\base\Object__construct($config)`
    Component::__construct($config);
}

上面方法中 Component::__construct($config) 會(huì)調(diào)用 yii\base\Object::__construct() 方法

  • yiibaseObject::__construct() 方法注解
public function __construct($config = [])
{
    if (!empty($config)) {
        // 將配置文件里面的所有配置信息賦值給Object。
        // 由于Object是大部分類的基類,
        // 實(shí)際上也就是有配置信息賦值給了yii\web\Application的對(duì)象
        Yii::configure($this, $config);
    }
    $this->init();
}

一、下面只是為了說(shuō)明 'components' => [ 'log' => [...]] 從哪來(lái),若不關(guān)心可以直接看 第二步。

  • 先看 $this->preInit($config);,即 yii\base\Application::preInit(&$config)
public function preInit(&$config)
{
    //others...
    
    // merge core components with custom components
    // 合并核心組件和自定義組件
    foreach ($this->coreComponents() as $id => $component) {
        if (!isset($config['components'][$id])) {
            // 若自定義組件中沒(méi)有設(shè)置該核心組件配置信息,直接使用核心組件默認(rèn)配置
            $config['components'][$id] = $component;
        } elseif (is_array($config['components'][$id]) && !isset($config['components'][$id]['class'])) {
            // 若自定義組件有設(shè)置該核心組件配置信息,但是沒(méi)有設(shè)置 'class'屬性,則添加該class屬性
            $config['components'][$id]['class'] = $component['class'];
        }
    }
}

/**
 * Returns the configuration of core application components.
 * 返回核心應(yīng)用組件的配置
 * @see set()
 */
public function coreComponents()
{
    return [
        // 日志分配器組件
        'log' => ['class' => 'yii\log\Dispatcher'],
        
        //others...
    ];
}
  • 經(jīng)過(guò) $this->preInit($config);, 我們得到的 $config
$config = [
    'modules' => [
        'debug' => [
            'class' => 'yii\debug\Module',
        ], 
        'gii'   => [
            'class' => 'yii\gii\Module',
        ];
    ],
    'components' => [
        'log'   => [
            'class' => 'yii\\log\\Dispatcher',
        ],
        
        //others...
    ]
    //others...
]


上面只是為了說(shuō)明 'components' => [ 'log' => [...]] 從哪來(lái)

二、重點(diǎn)在這里

  • yii\base\Object::__construct($config = []) 中的 Yii::configure($this, $config);
public static function configure($object, $properties)
{
    // 只是遍歷配置信息,賦值給當(dāng)前對(duì)象
    foreach ($properties as $name => $value) {
        $object->$name = $value;
    }
    return $object;
}
  • 這里我們要配合 yii\base\Object::__set($name, $value)
/**
 * 為實(shí)例不存在的屬性賦值時(shí)調(diào)用
 *
 * Do not call this method directly as it is a PHP magic method that
 * will be implicitly called when executing `$object->property = $value;`.
 * 這個(gè)是PHP的魔術(shù)方法,會(huì)在執(zhí)行 `$object->property = $value;` 的時(shí)候自動(dòng)調(diào)用。
 */
public function __set($name, $value)
{
    // setter函數(shù)的函數(shù)名
    // 由于php中方法名稱不區(qū)分大小寫,所以setproperty() 等價(jià)于 setProperty()
    $setter = 'set' . $name;
    if (method_exists($this, $setter)) {
        // 調(diào)用setter函數(shù)
        $this->$setter($value);
    } elseif (method_exists($this, 'get' . $name)) {
        // 如果只有g(shù)etter沒(méi)有setter 則為只讀屬性
        throw new InvalidCallException('Setting read-only property: ' . get_class($this) . '::' . $name);
    } else {
        throw new UnknownPropertyException('Setting unknown property: ' . get_class($this) . '::' . $name);
    }
}

當(dāng)前情景下的 $object 我們可以認(rèn)為是 yii\base\Application 的對(duì)象 $app

  • 當(dāng)遍歷到:
$app->modules =  [
    'debug' => [
        'class' => 'yii\debug\Module',
    ], 
    'gii'   => [
        'class' => 'yii\gii\Module',
    ];
]

這里會(huì)調(diào)用 yii\base\Module::setModules($modules) 方法

public function setModules($modules)
{
    foreach ($modules as $id => $module) {
        $this->_modules[$id] = $module;
    }
}

這樣便有了問(wèn)題中的

private "_modules" (yiibasemodule)=>
       array (size=3)
            'backend'  =>....
            'debug' =>...
            'gii'=>...
  • 同樣的道理,當(dāng)遍歷到:
$app->components =  [
    'log'   => [
        'class' => 'yii\\log\\Dispatcher',
    ],
]
  • 這里會(huì)調(diào)用 yii\di\ServiceLocator::setComponents($components) 方法
public function setComponents($components)
{
    foreach ($components as $id => $component) {
        $this->set($id, $component);
    }
}

public function set($id, $definition)
{
    // others ...

    if (is_object($definition) || is_callable($definition, true)) {
        // an object, a class name, or a PHP callable
        $this->_definitions[$id] = $definition;
    } elseif (is_array($definition)) {
        // 定義如果是個(gè)數(shù)組,要確保數(shù)組中具有 class 元素
        // a configuration array
        if (isset($definition['class'])) {
            // 定義的過(guò)程,只是寫入了 $_definitions 數(shù)組
            $this->_definitions[$id] = $definition;
        } else {
            throw new InvalidConfigException("The configuration for the \"$id\" component must contain a \"class\" element.");
        }
    } else {
        throw new InvalidConfigException("Unexpected configuration type for the \"$id\" component: " . gettype($definition));
    }
}

這樣便有了問(wèn)題中的

private  "_definitions"(yiidiservicelocator)=>
        array  (size=7)
           ...
           'log'=>...
           ...
陪她鬧 回答

建議全部轉(zhuǎn)為utf8mb4編碼。

ALTER TABLE <table_name> CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
未命名 回答

是不是沒(méi)有權(quán)限寫呀

拮據(jù) 回答

解決了 ,,換了一種方式,吧public的ui-view 放到 每一個(gè)小頁(yè)面的模板里面去了 這樣簡(jiǎn)單多了

陌南塵 回答

點(diǎn)擊全選的時(shí)候遍歷一遍復(fù)選框狀態(tài),然后統(tǒng)一改變所有狀態(tài),簡(jiǎn)單又粗暴