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

鍍金池/ 問答/ Python問答
不二心 回答

看樣子你使用的是 python3 吧?
在 python2 里面可以直接使用 bytes(1);而在 python3 里面 你還可以使用 bytes(str(1), 'utf8')。手動滑稽:)

艷骨 回答

發(fā)現(xiàn)哪錯了……
計算mid的時候應(yīng)該是

mid=(end+start)//2

這里把加號寫成減號了

陌顏 回答

你的 name 不是 str 喔!

我試著跑的結(jié)果:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-15-d43d76cb2656> in <module>()
     51         s = '\n'.join(sdata)
     52         str(s)
---> 53         saveFile(s, name)
     54         print(name[0].text + "保存成功")
     55         time.sleep(1)

<ipython-input-15-d43d76cb2656> in saveFile(data, name)
      6 
      7 def saveFile(data, name):
----> 8     path = name + ".txt"
      9     print(path)
     10     data.encode("utf-8")

TypeError: can only concatenate list (not "str") to list
不舍棄 回答

這個時候不是應(yīng)該重裝 node 嗎為什么想重裝 npm…

心癌 回答

你如果對計算過程詳細(xì)分析,就會發(fā)現(xiàn)其中的差別。python可變參數(shù)*para會將參數(shù)組成tuple存儲。因此,

adder1("god","damn","it") # 該函數(shù)執(zhí)行,args = ("god","damn","it")
adder1(["a","b"],["c","d"]) # 該函數(shù)執(zhí)行,args = (["a","b"],["c","d"])

python基礎(chǔ)牢固的,都知道

# 對于args = ("god","damn","it")
args[0][:0] = ''
# 對于args = (["a","b"],["c","d"])
args[0][:0] = []

很明顯是兩種不同的類型,一種是'',空字符串;一種是[]空的list。python里面,字符串和list都可以直接
進(jìn)行運算,所以有了上面的結(jié)果。

初念 回答

自己回答一下吧, 翻看了django1.7 bulk_create 的源碼, 上面有一段有意思的注釋:

# So this case is fun. When you bulk insert you don't get the primary
# keys back (if it's an autoincrement), so you can't insert into the
# child tables which references this. There are two workarounds, 1)
# this could be implemented if you didn't have an autoincrement pk,
# and 2) you could do it by doing O(n) normal inserts into the parent
# tables to get the primary keys back, and then doing a single bulk
# insert into the childmost table. Some databases might allow doing
# this by using RETURNING clause for the insert query. We're punting
# on these for now because they are relatively rare cases.

解決方法有兩種, 1)主鍵不設(shè)置為自增長,意思是需要自己指定主鍵的值嘍?沒理解錯吧
2)老老實實的一條條的插入吧

想了一下還是一條條插入,放到事務(wù)里面去操作. 不知道還有沒有更好的辦法

終相守 回答

pycharm 項目的 python 環(huán)境與系統(tǒng) python 環(huán)境不一致。

孤星 回答

我一直以為 Blueprint 中的 name 參數(shù)和 url_for 中所用到的 endpoint (端點)有關(guān),下面是我為什么這樣理解的。

首先,我們看一下 flask 的源碼: https://github.com/pallets/fl...
其中,有下面的代碼:

class Blueprint(_PackageBoundObject):
    ...
    ...
    def __init__(self, name, import_name, static_folder=None,
                 static_url_path=None, template_folder=None,
                 url_prefix=None, subdomain=None, url_defaults=None,
                 root_path=None):
        _PackageBoundObject.__init__(self, import_name, template_folder,
                                     root_path=root_path)
        self.name = name
        self.url_prefix = url_prefix
        self.subdomain = subdomain
        self.static_folder = static_folder
        self.static_url_path = static_url_path
        self.deferred_functions = []
        if url_defaults is None:
            url_defaults = {}
        self.url_values_defaults = url_defaults

上面的代碼可以明顯的看到, Blueprint 類繼承了 _PackageBoundObject,其中,name 參數(shù),可是該類自己定義的,那么,我們繼續(xù)在源碼中找 name 參數(shù)的作用。

在該類中尋找 self.name, 我們可以看到另外 8 處內(nèi)容, 分別在該類的 before_request、after_request、teardown_request、context_processor、url_value_preprocessor、url_defaults、errorhandler、register_error_handle 這 8 個類函數(shù)中,基本上函數(shù)中用到的地方都是:

 self.record_once(lambda s: s.app.before_request_funcs
            .setdefault(self.name, []).append(f))

那么,我們再看看這個 record_once 函數(shù)的作用,該函數(shù)也是在該類中定義的。

    def record_once(self, func):
        """Works like :meth:`record` but wraps the function in another
        function that will ensure the function is only called once.  If the
        blueprint is registered a second time on the application, the
        function passed is not called.
        """
        def wrapper(state):
            if state.first_registration:
                func(state)
        return self.record(update_wrapper(wrapper, func))

通過注釋,很明顯地看到這個函數(shù)的作用是為了將 name 參數(shù)作為唯一標(biāo)識來在程序中區(qū)分藍(lán)圖所用的。

那么,回到題主的問題。
一、之所以可以隨便定義名稱,感覺沒有什么影響,那是錯覺。

  • 第一個原因,你值定義了一個藍(lán)圖,如果你再定義一個,你把 name 的參數(shù)設(shè)置成一樣的,你試試程序會不會報錯。
  • 第二個原因,你沒有用到 url_for 函數(shù),這個函數(shù)中會用到你的 name 參數(shù),或者你是直接在這樣簡化的調(diào)用的 url_for('.index') 函數(shù)的, 那個 '.' 代表了當(dāng)前的藍(lán)圖。
  • 還是回到 url_for 函數(shù),如果你在 html 的 jinja2 中調(diào)用,你得這樣寫 url_for('name.index'),其中的 name 就是你定義的藍(lán)圖的 name 參數(shù)。

二、你可以試試如果不定義 name 參數(shù),程序會報錯,因為這個參數(shù)是必須的。

  • 在 view 視圖中,我們使用 裝飾器 的寫法,一般是把函數(shù)名稱當(dāng)做 endpoint 的,如果你在兩個不同的藍(lán)圖中,使用同一個名稱來定義視圖函數(shù),那么 endpoint 按照默認(rèn)方案就無法是唯一標(biāo)識了,必須得加上藍(lán)圖的名稱,所以藍(lán)圖的名稱也得是唯一的。
幼梔 回答

Debian:
pip uninstall M2crypto
apt install python-m2crypto -y

孤酒 回答

思路: 先查出注冊用記的類型, 然后再用戶類型的數(shù)組再循環(huán)訂單中所有的商品.

//語句可查出第一列(用戶類型) 最后一列(金額)
select m.uid,a.id,
                    sum((select 
                        sum((select sum(p.num * p.price) from {$pfix}d p where p.oid = o.id)
                    ) as user_amount
                    from {$pfix}c o where o.uid = m.uid)) as user_order_total
                    from {$pfix}b m 
                    JOIN {$pfix}a a ON m.aid = a.id
                    group by a.id
//查出所以訂單的商品類型
select product_id,product_name from {$pfix}d group by product_id
//循環(huán)出上列表格
        foreach ($data as $key => $value) { //AND o.create_time > 1516204800 下單時間條件
            $userSql = "select o.id from {$pfix}b m 
                        RIGHT JOIN {$pfix}c o ON o.uid = m.uid where m.aid= {$value ['id']} {$where}
            "; //查出用戶類型下所有用戶訂單
            $userData = $model->query($userSql);
            if(!empty($userData)) {
                
                $userWhere = implode(',', array_column($userData, 'id'));
                foreach ($productData as $k => $v) {
                    $amountSql = "select sum(num) as amount_total from {$pfix}d where product_id = {$v ['product_id']} AND oid IN({$userWhere})";
                    $amount = $model->query($amountSql);
                    $amount = $amount [0]['amount_total'];
                    $data [$key]['product'][$v ['product_id']] = array('amount_total' => $amount);
                }
                dump($productData);
            }
        }
陌上花 回答

好像很多初學(xué)者都會遇到這種錯誤,主 python 文件名與某個模塊的名稱相同了。

本例中,主文件是 aiohttp.py,它與 aiohttp 模塊沖突了。你的代碼所導(dǎo)入的 aiohttp 實際上是主文件 aiohttp.py。

孤星 回答

你的帳號需要付款

絯孑氣 回答

最后的解決辦法是調(diào)整swipe()里面的t取值為140左右可以滑倒比較后面。但是要滑到底部還是不夠

有你在 回答

503是request錯誤導(dǎo)致的,檢查了request有問題

慢半拍 回答

3D圖形好像沒有填充方法,需要先轉(zhuǎn)換成3D Polygon。下面是我根據(jù)SO上的一個回答寫的一個測試,你自己體會一下吧。
注:這個方法來自SO,原帖地址:https://stackoverflow.com/que...,不明白的可以去原貼查看。

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from mpl_toolkits.mplot3d.art3d import Poly3DCollection

size = 40 
x = [[0] * size] * size
y = list(map(sorted, np.random.rand(size, size)))
z = list(map(sorted, np.random.rand(size, size)))
vect = []
for i in range(size):
    vect.append(list(zip(x[i], y[i], z[i])))
poly3dCollection = Poly3DCollection(vect)

fig = plt.figure()
ax = Axes3D(fig)
ax.add_collection3d(poly3dCollection)
ax.set_xlim([-1, 1])
ax.set_xlabel("x")
ax.set_ylabel("y")
ax.set_zlabel("z")

plt.show()

圖片描述

忠妾 回答

clipboard.png
分析了一下。由上圖可以看出來其實是有兩個span
一個放著簡介的內(nèi)容,一個放著全部展開的內(nèi)容,
是通過控制這兩個span的顯隱來決定顯示的是簡介還是全部的內(nèi)容。

要獲得全部的內(nèi)容,抓取<span class="all"></span>中的內(nèi)容即可

凹凸曼 回答

使用隱私瀏覽功能時,瀏覽器不會保存訪問過的網(wǎng)站、看過的網(wǎng)頁等信息。

有兩種方式可以開始隱私瀏覽:

打開新的空白隱私瀏覽窗口:點擊菜單按鈕,再點擊 新建隱私瀏覽窗口 按鈕。

在隱私瀏覽窗口中打開鏈接:右擊
鏈接,在上下文菜單中選擇 在新隱私瀏覽窗口中打開鏈接。

注意:隱私瀏覽模式并不會讓您匿名地瀏覽網(wǎng)絡(luò)。您的網(wǎng)絡(luò)提供商,雇主或瀏覽過的網(wǎng)站本身依然可以追蹤到您訪問的頁面。此外,隱私瀏覽不能保護(hù)您免遭在您計算機(jī)上安裝的 鍵盤記錄 或 間諜軟件 的侵害。

悶油瓶 回答

==和is如何選擇?

==運算符比較兩個對象的值,可以使用__eq__魔術(shù)方法重載實現(xiàn)自定義比較。
is比較兩個對象的id標(biāo)識,不能重載,通常用于變量和單例值直接的比較,比如is None。

為什么有時id相同?

首先id并不會因為是不可變類型就相同。
Cpython有一種叫駐留(interning)的細(xì)節(jié)優(yōu)化手段,會為字符串還有小的整數(shù)做出優(yōu)化,共享同一個引用。
但是注意這種優(yōu)化既不適用不可變類型,也不適用所有的字符串和整數(shù),具體情況參考源碼實現(xiàn)。

來守候 回答

你域名解析的是 www ,你的cname 中應(yīng)該是 www.mynotes.work