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

鍍金池/ 問答/ Python問答
孤影 回答

因?yàn)橛袝r(shí)區(qū),mktime是本地時(shí)區(qū)
https://docs.python.org/3/lib...

>>> int(time.mktime(time.strptime('2018-03-08 00:00:00', "%Y-%m-%d %H:%M:%S")))
1520438400    # 北京時(shí)間
>>> time.tzname
('CST', 'CST')
>>> time.timezone
-28800    # 8小時(shí)
from datetime import datetime
datetime.now().strftime('%Y-%m-%d 23:59:00')
笑忘初 回答

因?yàn)槭侵祩鬟f,或者說(shuō),在函數(shù)里面的 a b 和外面的 a b 不是同一個(gè)變量。

python 交換 2 個(gè)基本類型的變量可以這樣寫:

a, b = b, a
抱緊我 回答

可以用gevet啊

from gevent import monkey
from gevent.pywsgi import WSGIServer
monkey.patch_all()
from flask import Flask
import time

app = Flask(__name__)

@app.route('/test',methods=['GET'])
def sayHello():
    time.sleep(10)
    return 'hello'

@app.route('/hi',methods=['GET'])
def sayHi():
    return 'hi'
if __name__ =='__main__':
    http_server = WSGIServer(('', 5000), app)
    http_server.serve_forever()

測(cè)試結(jié)果:
127.0.0.1 - - [2017-12-12 22:35:10] "GET /test/ HTTP/1.1" 200 126 0.000000
127.0.0.1 - - [2017-12-12 22:35:11] "GET /test/ HTTP/1.1" 200 126 0.000000
127.0.0.1 - - [2017-12-12 22:35:11] "GET /test/ HTTP/1.1" 200 126 0.000000
127.0.0.1 - - [2017-12-12 22:35:12] "GET /test/ HTTP/1.1" 200 126 0.000000
127.0.0.1 - - [2017-12-12 22:35:12] "GET /test/ HTTP/1.1" 200 126 0.000998
127.0.0.1 - - [2017-12-12 22:35:13] "GET /test/ HTTP/1.1" 200 126 0.001001
127.0.0.1 - - [2017-12-12 22:35:14] "GET /test/ HTTP/1.1" 200 126 0.000000
127.0.0.1 - - [2017-12-12 22:35:14] "GET /test/ HTTP/1.1" 200 126 0.001014
127.0.0.1 - - [2017-12-12 22:35:15] "GET /test/ HTTP/1.1" 200 126 0.001000
127.0.0.1 - - [2017-12-12 22:35:15] "GET /test/ HTTP/1.1" 200 126 0.000000
127.0.0.1 - - [2017-12-12 22:35:18] "GET /asyn/ HTTP/1.1" 200 126 10.000392

我以為 回答

這不小學(xué)問題么,不知道你想問什么,或者你覺得難的地方是什么。

不將就 回答

具有 true 和 false 兩個(gè)屬性的屬性,如 checked, selected 或者 disabled 使用prop(),其他的使用 attr()

補(bǔ)充一下,其實(shí)你用attr也可以,但是取消勾選的時(shí)候要用removeAttr('checked')

骨殘心 回答

hack 一下:

config.module
        .rule('expose')
            .test(require.resolve('jquery'))
            .use('expose-loader')
                .loader('expose-loader')
                .options('$')
                .end()
            .use('a-loader')
                .loader('expose-loader')
                .options('jQuery')
離人歸 回答

你定義了變量pwd卻沒用?筆誤吧

傲寒 回答

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

厭遇 回答

input 沒有雙向綁定
<input type="text" v-model="item.number" v-on:change="changeFn()">

初念 回答

自己回答一下吧, 翻看了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è)置為自增長(zhǎng),意思是需要自己指定主鍵的值嘍?沒理解錯(cuò)吧
2)老老實(shí)實(shí)的一條條的插入吧

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

這也是一種間接的默認(rèn)標(biāo)準(zhǔn)吧,太少了不行(太少有可能嘗試出正確數(shù)),太多了也不行,4~6為最好,6位最佳,你看支付寶支付、微信支付6位,銀行卡密碼6位

終相守 回答

剛寫了一篇關(guān)于yield的文章,樓主可以參考一下;

當(dāng)我們調(diào)用yield,它究竟做了什么

寫點(diǎn)我的理解:

第一次調(diào)用sq.send(7)時(shí),代碼執(zhí)行到了:

response=yield cursor**2

此時(shí),response的值是7,然后執(zhí)行

cursor+=1 # cursor已經(jīng)是3了

然后接著下一次循環(huán),此時(shí):

if response:
  response = yeild response*2

返回49,而接下來(lái)當(dāng)輸入next(sq)時(shí),response沒有被顯式賦值,所以response又變成了None;然后接著運(yùn)行:

continue

然后正常往下走。

乞許 回答

print(i,i,i)


>>> sum([[i]*3 for i in range(0,120,60)],[])
[0, 0, 0, 60, 60, 60]

>>> def gen():
    for i in range(0,120,60):
        yield i
        yield i
        yield i

        
>>> for n in gen():
    print(n)

    
0
0
0
60
60
60
>>> 
糖果果 回答

我也遇到你的問題。經(jīng)過的半天的折騰,最終發(fā)現(xiàn)是自己在根目錄下面建立一個(gè)新文件夾。然后我重裝系統(tǒng),沒有在根目錄下面建立新文件夾或者文件,就沒有出現(xiàn)這個(gè)問題了。
犯的錯(cuò)誤是這個(gè):

  • cd /

  • mkdir downloads

  • wget

如果是和我一樣的錯(cuò)誤,第一,重裝系統(tǒng)可以解決。第二,你可以試試將你新建立的文件或者文件夾給刪除了。

巴扎嘿 回答

經(jīng)過一個(gè)晚上的嘗試,最終發(fā)現(xiàn)時(shí)SSL的問題,需要用代碼禁用一下,便可以成功訪問

孤影 回答
用replace函數(shù)替換文本中的< br >或者<br/>
#!/usr/bin/env python
# -*- coding:utf-8 -*-

from bs4 import BeautifulSoup

html_doc='''
<tr>
    <td>1</td>
    <td>2(一心<br>一意)</td>
    <td>3(兩全<br/>齊美)</td>
    <td>放棄1次<br/>        
    </td>
</tr>
'''
soup=BeautifulSoup((html_doc.replace('<br>','')).replace('<br/>',''),'lxml')

for i in soup.find_all('td'):
    print(i.string)

圖片描述

遺莣 回答

關(guān)于scrapy無(wú)法下載html內(nèi)容的問題

會(huì)不會(huì)是scrapy默認(rèn)開啟了遵守Robots.txt 導(dǎo)致的?嘗試在settings.py中改一下.

在我這是默認(rèn)打開的, 內(nèi)容是如下:

Obey robots.txt rules
ROBOTSTXT_OBEY = True
我這里測(cè)試, 發(fā)現(xiàn) 是否 改變r(jià)obots為False, 同時(shí) 是否 增加用戶代理, 內(nèi)容都可以被成功下載.

關(guān)于xpath的問題

的確存在這個(gè)問題, 可能是小幾率的xpath失效的問題 -> (我猜測(cè)是這個(gè)問題), 因?yàn)槲覈L試過在瀏覽器中使用我寫的xpath發(fā)現(xiàn)是可以獲取的, 但是scrapy中并不行.

原文章: "在使用chrome等瀏覽器自帶的提取extract xpath路徑的時(shí)候, 通?,F(xiàn)在的瀏覽器都會(huì)對(duì)html文本進(jìn)行一定的規(guī)范化,
導(dǎo)致明明在瀏覽器中提取正確, 卻在程序中返回錯(cuò)誤的結(jié)果."

我嘗試過使用相對(duì)路徑, 發(fā)現(xiàn)也不行, 我建議你這里使用regex正則表達(dá)式來(lái)提取.
我寫的正則不是特別簡(jiǎn)潔, 但是可以提取表格內(nèi)的所有內(nèi)容, 以列表(二維數(shù)組)形式被存下來(lái).

regex = re.compile(r"([:\u4e00-\u9fa50-9\(\)]+)</td>\s*[<td colspan=\"5\">]*[<td>]*([,\[\]\.0-9\u4e00-\u9fa5]+)</td>")

共找到 8 處匹配:(每處匹配的都是內(nèi)容, 不包含html標(biāo)簽.)
宗地編號(hào)</td>    <td>唐國(guó)土豐南告字[2018]2號(hào)公告地塊</td>
地塊位置</td>    <td>豐南區(qū)豐南鎮(zhèn)楊貴莊村西</td>
土地用途</td>    <td>其他普通商品住房用地</td>
土地面積(公頃)</td>    <td>0.676247</td>
出讓年限</td>    <td>70年</td>
成交價(jià)(萬(wàn)元)</td>    <td>508</td>
受讓單位</td>    <td colspan="5">北京睿博大正投資有限公司</td>
土地使用條件:</td>    <td colspan="5">該宗地規(guī)劃用途為居住用地,使用年限為住宅70年商業(yè)40年</td>              


瘋浪 回答

親測(cè)沒有任何作用。
想流暢,輸出后應(yīng)該用 sys.stdout.flush 清空緩沖區(qū)。

悶油瓶 回答

安裝多版本python的命令行python版本問題?解決:python -V 或者py -V,python3 -V
安裝env環(huán)境控制問題?解決:pip3 install sqlalchemy