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

鍍金池/ 問(wèn)答/ Python問(wèn)答

首先回答第一個(gè)問(wèn)題

你要求的是 在 notice 表中存在,檢索的時(shí)候 排除notice表中有的數(shù)據(jù)

你可以這樣做,不需要模型關(guān)聯(lián)

首先,取出 notice 表中的數(shù)據(jù),只需要取出 user_id 字段的數(shù)據(jù)

public function getData(Notice $notic , User $user)
{

    $userIds = $notic->all()->pluck('user_id')->toArray();

    $users = $user->query()->whereNotIn('id' , $userIds)->get();

    dd( $users);
}
pluck 方法為給定鍵獲取所有集合值 , 在通過(guò) 查詢語(yǔ)句,使用 whereNotIn的 方式 查詢數(shù)據(jù)

第二個(gè)問(wèn)題 查詢當(dāng)前用戶的通知列表

不是通過(guò)自增 id 來(lái)查詢,前 100 條數(shù)據(jù),

如果是使用 sql 語(yǔ)句查詢 , 則使用 limit 0,100

使用laravel的話,則有一個(gè)take方法, 例如take(100)

hasWhere laravel 中好像沒(méi)有這個(gè)方法噢
敢試 回答

你可以查看一下我的項(xiàng)目里的 config.py :https://github.com/eastossifrage/pyblog/blob/master/config.py

SQLALCHEMY_COMMIT_ON_TEARDOWN = True

這一項(xiàng)就是你想要的。

有你在 回答

就是 http://yourIP:5555
如果是VPS,防火墻什么的得配置,保證這個(gè)端口可以訪問(wèn)。如果是家庭寬帶,需要路由器做端口映射

夢(mèng)囈 回答

多少時(shí)間不算慢?
可以看下 https://docs.opencv.org/2.4/d... 特征提取找映射的方法。
這樣即使圖片有縮放和輕度旋轉(zhuǎn)一樣能搞定。
遍歷的話,考慮下GPU加速。沒(méi)有GPU的話也可進(jìn)行多線程等優(yōu)化。

尋仙 回答

不是python程序員,不過(guò)分享一些對(duì)于樹(shù)形結(jié)構(gòu)的研究。
如果你用的數(shù)據(jù)庫(kù)支持層次化查詢最好。比如Oracle的Connect By或者其他數(shù)據(jù)庫(kù)的CTE.由數(shù)據(jù)庫(kù)幫你計(jì)算Level, Path, IS_LEAF最好,否者利用程序去實(shí)現(xiàn)Lazy Load會(huì)比較麻煩。對(duì)于CTE的支持現(xiàn)在越來(lái)越普及了,可以考慮。

數(shù)據(jù)庫(kù)中實(shí)現(xiàn)樹(shù)形結(jié)構(gòu)有兩種方式:adjacent list和nested set。一般都是前者

眼雜 回答

cgi了解一下,只要是可執(zhí)行程序都可以

兔寶寶 回答
$arr = array(
        array('id'=>'1','name'=>'a'),
        array('id'=>'1','name'=>'b'),
        array('id'=>'1','name'=>'c'),
        array('id'=>'2','name'=>'d'),
        array('id'=>'2','name'=>'e'),
    );
    
    
    $result = array();
    
    foreach ($arr as $value) {
        $result[$value['id']]['id'] = $value['id'];
        $result[$value['id']]['name'][] = $value['name'];
    }
    $result = array_values($result);
    print_r($result);

函數(shù)自己封裝吧

孤巷 回答

settings.py里的STATICFILES_DIR不應(yīng)該是STATICFILES_DIRS嗎?

可以考慮用腳本的方式實(shí)現(xiàn),vpn連接和flask的啟動(dòng)放在一個(gè)腳本里。當(dāng)vpn連接成功后,執(zhí)行啟動(dòng)flask的語(yǔ)句,如python path/to/run.py。提供個(gè)思路...

空痕 回答

是float64轉(zhuǎn)float32時(shí)出了問(wèn)題

維她命 回答

經(jīng)過(guò)嘗試,使用 python 可以實(shí)現(xiàn)。
前面的做法 filter 返回的是 python 的list,并不能直接作為數(shù)組使用,需要將其轉(zhuǎn)化為字符串,再返回就 OK 了。

原因:對(duì) python 的數(shù)據(jù)結(jié)構(gòu)理解不夠

實(shí)現(xiàn)如下:

def to_join_http_port(nodes, hostvars, ansible_default_netname, port):
    """
    INPUT:
        nodes: groups.group_name
        hostsvars: ansible Built-in vars
        ansible_default_netname: ethernet name
        port: program server port
    RETURN:
        string like '"http://10.32.254.7:8081","http://10.32.254.8:8081","http://10.32.254.11:8081"'
    """
    ips = []
    for node in nodes:
        ips.append(hostvars[node][ansible_default_netname]["ipv4"]["address"])
    return ",".join([ '"http://%s:%s"' % (ip, port) for ip in ips ])


class FilterModule(object):
    def filters(self):
        return {
            'http_port_join': to_join_http_port
        }
扯不斷 回答

演示程序地址-三十客

$(document).ready(function () {
    var $texta = $('#my-textarea');
    var lastWidth = localStorage.getItem("my-area-width");
    var lastHeight = localStorage.getItem("my-area-height");
    if(lastWidth && lastHeight) {
        $texta.css("width",lastWidth+"px");
        $texta.css("height",lastHeight+"px");
    }
    $texta.data('x', $texta.outerWidth());
    $texta.data('y', $texta.outerHeight());
    $texta.mouseup(function () {
        var $this = $(this);
        var width = $this.outerWidth();
        var height = $this.outerHeight();
        if (width != $this.data('x') || height != $this.data('y')) {
            alert(width + ' - ' + $this.data('x') + '\n' + height + ' - ' + $this.data('y'));
            localStorage.setItem("my-area-width",width);
            localStorage.setItem("my-area-height",height);
        }
        $this.data('x', width);
        $this.data('y', height);
    });
});
笨小蛋 回答
osp = form.save(commit=True)
osp.order.add(*order_goods) 
# osp.save()

m2m 關(guān)系只有當(dāng)兩邊都在數(shù)據(jù)庫(kù)中存在時(shí)才能添加

病癮 回答

swoole連RFC6455都沒(méi)完全實(shí)現(xiàn),壓縮擴(kuò)展也沒(méi)有……雖然不影響基本的使用,但是超出了swoole支持的范圍就不方便了。

而python的websockets,完整實(shí)現(xiàn)RFC6455,有uvloop(Cython + libuv)IO也性能不會(huì)差。

清夢(mèng) 回答

當(dāng)任務(wù)運(yùn)行時(shí)間長(zhǎng)的時(shí)候,我有的時(shí)候可能想會(huì)停止這個(gè)任務(wù)進(jìn)行調(diào)整

如果只是這個(gè)目的,加一個(gè)time_limit的修飾器不就可以了?

@task(time_limit=20)
def your_task():
尋仙 回答

查一下文檔:

陌顏 回答

已在api文檔中找到方法,使用 Alert(browser).text來(lái)獲取彈窗的文本