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

鍍金池/ 問答/ Python問答
終相守 回答

response = requests.get("http://wxqqyy.info/thread-9227343-1-1.html", headers={"Accept-Encoding" : ""})

魚梓 回答

< 在界面寫吧 或者網(wǎng)站找個(gè)小于符號 不用鍵盤打出來的小于號

短嘆 回答

大概是這樣:

import requests
import re

url_list = ['http://top.chinaz.com/hangye/index_news.html']
url_list.extend(['http://top.chinaz.com/hangye/index_news_{}.html'.format(pages) for pages in range(2, 68)])

DOMAIN = 'http://top.chinaz.com'

def parse_detail(url):
    full_url = DOMAIN + url
    print('process:', full_url)
    res = requests.get(full_url)
    res.encoding = 'utf-8'
    content = res.text
    web_name = re.search('<h2 class="h2Title fl">(.*?)</h2>', content).group(1)
    web_url = re.search('<h2 class="h2Title fl">.*?</h2><p.*?href="(.*?)" target="_blank" >.*?</a>', content).group(1)
    web_description = re.search('<p class="webIntro">(.*?)</p>', content).group(1)
    print('網(wǎng)站名稱:' + web_name)
    print('網(wǎng)址:' + web_url)
    print('網(wǎng)站簡介:' + web_description)

for url in url_list:
    print('list:', url)
    res = requests.get(url)
    res.encoding = 'utf-8'
    content = res.text
    detail_urls = re.findall('<div class="leftImg"><a name=".*?href="(.*?)">', content)

    for url in detail_urls:
        parse_detail(url)

我回答過的問題: Python-QA

小曖昧 回答

錯(cuò)誤提示是ValueError: Unknown string format, 所以就指定format:

import pandas as pd

df = pd.DataFrame(data={'time': ['1 days 02:59:45.000000000']})
df['time'] = pd.to_datetime(df['time'], format='%d days %H:%M:%S.%f').values.astype('datetime64[h]')
df

不知道是不是你所需要的.

背叛者 回答

無關(guān)。
這個(gè)字段有兩個(gè)名字,一個(gè)是 d_type_id,它是 python 層面的;另一個(gè)是 device_type_id,它是最終存在數(shù)據(jù)庫中的列名。而你通過實(shí)例 Device 訪問,是在 python 層面的,如果訪問 device_type_id 是會報(bào)錯(cuò)的:

>>> d.device_type_id
Traceback (most recent call last):
  File "<console>", line 1, in <module>
AttributeError: 'Device' object has no attribute 'device_type_id'

你在 python shell 中查看 dir(Device) 或者 dir(d) 都是找不到 device_type_id 的,只有 'd_type', 'd_type_id',:

>>> d.d_type  # 一個(gè) DeviceType 實(shí)例
<DeviceType: first type>
>>> d.d_type_id  # device_type_id 列內(nèi)存儲值
1

log_df[['id','device']].groupby(['id'])['device'].apply(lambda x:len(set(x)))

葬愛 回答

應(yīng)該使用模型操作。 可以先看一下QT的 MVC架構(gòu)

骨殘心 回答

app.run()
它是調(diào)用flask內(nèi)置的自己實(shí)現(xiàn)的一個(gè)單線程服務(wù)器,通常是用在開發(fā)測試的情況下,因?yàn)檎鎸?shí)情況下必須考慮到并發(fā),nginx + gunicorn,是利用nginx高并發(fā)的優(yōu)勢,nginx收到http請求之后,把他轉(zhuǎn)發(fā)給wsgi服務(wù)器gunicorn,gunicorn上運(yùn)行flask應(yīng)用,處理請求之后再返回給nginx

下面這段是flask run函數(shù)的源碼,你可以找來看看

from werkzeug.serving import run_simple

try:
    run_simple(host, port, self, **options)
finally:
    # reset the first request information if the development server
    # reset normally.  This makes it possible to restart the server
    # without reloader and that stuff from an interactive shell.
    self._got_first_request = False
陪我終 回答

Quite simple:

>>> print '"Hello,\\nworld!"'.decode('string_escape')
"Hello,
world!"

>>> data = json.loads('{\"count\":8,\"sub_images\":[{\"url\":\"http:\\/\\/p3.pstatp.com\\/origin\\/470700000c7084773fb2\",\"width\":1178,\"url_list\":[{\"url\":\"http:\\/\\/p3.pstatp.com\\/origin\\/470700000c7084773fb2\"},{\"url\":\"http:\\/\\/pb9.pstatp.com\\/origin\\/470700000c7084773fb2\"},{\"url\":\"http:\\/\\/pb1.pstatp.com\\/origin\\/470700000c7084773fb2\"}],\"uri\":\"origin\\/470700000c7084773fb2\",\"height\":1590},{\"url\":\"http:\\/\\/p9.pstatp.com\\/origin\\/47050001b69355a0bf1b\",\"width\":1178,\"url_list\":[{\"url\":\"http:\\/\\/p9.pstatp.com\\/origin\\/47050001b69355a0bf1b\"},{\"url\":\"http:\\/\\/pb1.pstatp.com\\/origin\\/47050001b69355a0bf1b\"},{\"url\":\"http:\\/\\/pb3.pstatp.com\\/origin\\/47050001b69355a0bf1b\"}],\"uri\":\"origin\\/47050001b69355a0bf1b\",\"height\":1557},{\"url\":\"http:\\/\\/p3.pstatp.com\\/origin\\/470300020761150d671a\",\"width\":1178,\"url_list\":[{\"url\":\"http:\\/\\/p3.pstatp.com\\/origin\\/470300020761150d671a\"},{\"url\":\"http:\\/\\/pb9.pstatp.com\\/origin\\/470300020761150d671a\"},{\"url\":\"http:\\/\\/pb1.pstatp.com\\/origin\\/470300020761150d671a\"}],\"uri\":\"origin\\/470300020761150d671a\",\"height\":1552},{\"url\":\"http:\\/\\/p1.pstatp.com\\/origin\\/47000002200f2a0a9020\",\"width\":1178,\"url_list\":[{\"url\":\"http:\\/\\/p1.pstatp.com\\/origin\\/47000002200f2a0a9020\"},{\"url\":\"http:\\/\\/pb3.pstatp.com\\/origin\\/47000002200f2a0a9020\"},{\"url\":\"http:\\/\\/pb9.pstatp.com\\/origin\\/47000002200f2a0a9020\"}],\"uri\":\"origin\\/47000002200f2a0a9020\",\"height\":1575},{\"url\":\"http:\\/\\/p1.pstatp.com\\/origin\\/470000022011d5569ccb\",\"width\":1178,\"url_list\":[{\"url\":\"http:\\/\\/p1.pstatp.com\\/origin\\/470000022011d5569ccb\"},{\"url\":\"http:\\/\\/pb3.pstatp.com\\/origin\\/470000022011d5569ccb\"},{\"url\":\"http:\\/\\/pb9.pstatp.com\\/origin\\/470000022011d5569ccb\"}],\"uri\":\"origin\\/470000022011d5569ccb\",\"height\":1588},{\"url\":\"http:\\/\\/p3.pstatp.com\\/origin\\/4700000220127db96444\",\"width\":1178,\"url_list\":[{\"url\":\"http:\\/\\/p3.pstatp.com\\/origin\\/4700000220127db96444\"},{\"url\":\"http:\\/\\/pb9.pstatp.com\\/origin\\/4700000220127db96444\"},{\"url\":\"http:\\/\\/pb1.pstatp.com\\/origin\\/4700000220127db96444\"}],\"uri\":\"origin\\/4700000220127db96444\",\"height\":1561},{\"url\":\"http:\\/\\/p3.pstatp.com\\/origin\\/46ff000532e33a9fa35a\",\"width\":1178,\"url_list\":[{\"url\":\"http:\\/\\/p3.pstatp.com\\/origin\\/46ff000532e33a9fa35a\"},{\"url\":\"http:\\/\\/pb9.pstatp.com\\/origin\\/46ff000532e33a9fa35a\"},{\"url\":\"http:\\/\\/pb1.pstatp.com\\/origin\\/46ff000532e33a9fa35a\"}],\"uri\":\"origin\\/46ff000532e33a9fa35a\",\"height\":1563},{\"url\":\"http:\\/\\/p9.pstatp.com\\/origin\\/470700000c7b871a5fae\",\"width\":1178,\"url_list\":[{\"url\":\"http:\\/\\/p9.pstatp.com\\/origin\\/470700000c7b871a5fae\"},{\"url\":\"http:\\/\\/pb1.pstatp.com\\/origin\\/470700000c7b871a5fae\"},{\"url\":\"http:\\/\\/pb3.pstatp.com\\/origin\\/470700000c7b871a5fae\"}],\"uri\":\"origin\\/470700000c7b871a5fae\",\"height\":1575}],\"max_img_width\":1178,\"labels\":[],\"sub_abstracts\":[\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \"],\"sub_titles\":[\"\\u6e05\\u65b0\\u81ea\\u7136\\uff0c\\u7f8e\\u4e3d\\u65e0\\u53cc\",\"\\u6e05\\u65b0\\u81ea\\u7136\\uff0c\\u7f8e\\u4e3d\\u65e0\\u53cc\",\"\\u6e05\\u65b0\\u81ea\\u7136\\uff0c\\u7f8e\\u4e3d\\u65e0\\u53cc\",\"\\u6e05\\u65b0\\u81ea\\u7136\\uff0c\\u7f8e\\u4e3d\\u65e0\\u53cc\",\"\\u6e05\\u65b0\\u81ea\\u7136\\uff0c\\u7f8e\\u4e3d\\u65e0\\u53cc\",\"\\u6e05\\u65b0\\u81ea\\u7136\\uff0c\\u7f8e\\u4e3d\\u65e0\\u53cc\",\"\\u6e05\\u65b0\\u81ea\\u7136\\uff0c\\u7f8e\\u4e3d\\u65e0\\u53cc\",\"\\u6e05\\u65b0\\u81ea\\u7136\\uff0c\\u7f8e\\u4e3d\\u65e0\\u53cc\"]}'.decode('string_escape'))
>>> 
>>> data["count"]
8
>>> 
何蘇葉 回答

也是新手 看到紅色就當(dāng)成報(bào)錯(cuò)哈哈

怣人 回答

首先,找出獲取公司列表的接口地址:https://www.qichacha.com/gong...
然后,看看請求參數(shù):key,type
如果還是不行,那就可能還有別的參數(shù)校驗(yàn)規(guī)則,通常是在請求頭里。比如cookie,或者別的自定義字段。

1.首選zen of python(import this即可看到Explicit is better than implicit.)中提到顯式勝于隱式,所以參數(shù)中必須有個(gè)首參數(shù)self或其他的名字,而不是像c++這種高級語言有隱式的作用域
2.為什么self不是關(guān)鍵字,原因很簡單Python是動態(tài)語言,比如你總是可以對普通的函數(shù)動態(tài)綁定為方法,所以不可能限定self關(guān)鍵字:

import types
class A:
    def __init__(self):
        self.bar = 'bar'

def foo(bar):
    print(bar.bar)

a = A()
a.foo = types.MethodType(foo, a)
a.foo()

3. 還想到一個(gè)題外話,有一個(gè)玩笑是“基于Python的 web framework比python的關(guān)鍵字還多”,于是有人和作者提議多加一些關(guān)鍵字,但是被拒絕了,這也印證了Zen of Python的另外兩句話:Simple is better than complex.Complex is better than complicated.

傲寒 回答

沒試過寫到service里面,不過親測寫到rc.local里面是可以的

笨小蛋 回答
osp = form.save(commit=True)
osp.order.add(*order_goods) 
# osp.save()

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

舊螢火 回答
a = [45, 67, 89, 90, 234, 67, 78123131, 4645645, 1231231]
b = ["qweqw", "qeqeqe", "sd", "fsdf"]

for i, v in enumerate(b):
    a.insert(i*3 + 2, v)

print a
忘了我 回答

1.cookie是在header里的
2.UA也是放header里的

隨便打開chrome的控制臺,你就能看到網(wǎng)絡(luò)請求,可以看出哪些是header,哪些是data,哪些是query string

clipboard.png

想要更深入的了解的話可以看看圖解http這本書

你的 app.config 里面沒有定義 FLASK_ADMIN

替身 回答

應(yīng)該是你定義的related_name和User的id屬性發(fā)生了沖突.
如果你沒有給外鍵定義related_name屬性,那么反向引用的時(shí)候就是: User.usrMes_set.all()
你添加了related_name='id'后就成了: User.id.all(), 這樣就和調(diào)用id屬性User.id有沖突了.

另外對同一個(gè)model的兩個(gè)外鍵,related_name不能重名

過客 回答

你不理解哪塊?

整體實(shí)現(xiàn)是有一個(gè)v-for所有notice類的組件。你每調(diào)用一次就往里push一個(gè)。


1.success->message

// 幾種方法最終都是調(diào)用message
success (options) {
    return this.message('success', options);
}

2.message-->notice

message(type, options){
        if (typeof options === 'string') {
            options = {
                content: options
            };
        }
        return notice(options.content, options.duration, type, options.onClose, options.closable);
    }

3.noitice-->getMessageInstance

function notice (content = '', duration = defaults.duration, type, onClose = function () {}, closable = false) {
    //...
    // 這個(gè)應(yīng)該是拿實(shí)例
    let instance = getMessageInstance()
    // 這個(gè)應(yīng)該是真正append到頁面上
    instance.notice({
        
    });

    // 用于手動消除,返回值不用管
    return (function () {
    })();
}

4.getMessageInstance-->Notification.newInstance

function getMessageInstance () {
    // 復(fù)用?
    messageInstance = messageInstance || Notification.newInstance({
    });
    return messageInstance;
}

5.iview/src/components/base/notification/index.js

Notification.newInstance = properties => {
    const _props = properties || {};
    // 創(chuàng)建了一個(gè)統(tǒng)一v-for所有notice類的組件
    const Instance = new Vue({
        data: _props,
        render (h) {
            return h(Notification, {
                props: _props
            });
        }
    });

    const component = Instance.$mount();
    document.body.appendChild(component.$el);
    return {
        // 3里有調(diào)用notice()的一步
        notice (noticeProps) {
            // 調(diào)了組件的add,向v-for隊(duì)列里加了一個(gè),去notification.vue能看到
            notification.add(noticeProps);
        }
    };