qs.stringify({ 'list':this.excelData },{ arrayFormat: 'brackets' })
arrayFormat 可以格式化你的數(shù)組參數(shù)
arrayformat選項(xiàng)輸出 指定數(shù)組的格式
qs.stringify({ id: ['b', 'c'] }, { arrayFormat: 'indices' })
// 'id[0]=b&id[1]=c'
qs.stringify({ id: ['b', 'c'] }, { arrayFormat: 'brackets' })
// 'id[]=b&id[]=c'
qs.stringify({ id: ['b', 'c'] }, { arrayFormat: 'repeat' })
// 'id=b&id=c'Python2版本里的/運(yùn)算結(jié)果取整數(shù),例如:
5 / 2 = 2;
2 / 3 = 0;
到了Python3里就變了;
5 / 2 = 2.5;
2 / 3 = 0.66...;
再有就是Python2和Python3兩個(gè)版本有些地方差別還是比較大的,兩個(gè)版本不是兼容的,使用時(shí)注意區(qū)分Python的版本;
少量用游標(biāo)算,大量用服務(wù)器算,畢竟服務(wù)器計(jì)算能力比Python快
看起來(lái) 0:4, 4:7,... 可視為數(shù)組的下標(biāo),可簡(jiǎn)化成元素個(gè)數(shù) 4, 3,...
那么問(wèn)題演變成“由同元素個(gè)數(shù)組成的序列,生成相應(yīng)的數(shù)組”,如下
def compute(*size_list):
l2 = []
for i, size in enumerate(size_list):
l2.extend([str(i+1)] * size)
return l2
def test_compute():
assert compute(4, 3, 2, 2, 1) == [
'1', '1', '1', '1',
'2', '2', '2',
'3', '3',
'4', '4',
'5',
]可以曲線救國(guó)
for name, content in enumerate(globals()):
if isinstance(content, list):
print(name, content)
這樣可以獲取到全局的list變量的名字
在windows里環(huán)境變量的改變需要重啟電腦
你的文件應(yīng)該先 open, 然后再read. 我下面的這個(gè)例子能夠正常work
#!/usr/bin/python
import csv
filename = './a.csv'
duration_list = []
with open(filename) as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
duration_list.append(row['duration'])
print duration_list
你要做的是用jstack查看線程狀態(tài),并且結(jié)合當(dāng)時(shí)的io與cpu情況做進(jìn)一步的分析。
經(jīng)實(shí)驗(yàn)及查看文檔發(fā)現(xiàn),find()函數(shù)返回的是類(lèi)型為cursor的值,而find_one()返回的是數(shù)組或?qū)ο?,故要訪問(wèn)返回的文檔的某個(gè)字段時(shí)根據(jù)使用的查詢(xún)函數(shù),若為resu = db.collection.find(),則可通過(guò)如下的方式訪問(wèn):
resu = db[username + "fileinfo"].find()
historyfilelist = []
try:
for ele in resu:
global historyfilelist
historyfilelist.append(ele["filename"])
return HttpResponse(json.dumps(historyfilelist))
若是采用的find_one()函數(shù),則可以直接通過(guò)字典訪問(wèn),(如下面的_id獲取的方式)
resu = db[fileinfo['username'] + "fileinfo"].find_one({"filename": filename})
if resu is None:
db[fileinfo['username'] + "fileinfo"].insert(fileinfo)
return HttpResponse(json.dumps({"Uploaded": []}))
elif resu["_id"] == md5:
上面方法親測(cè)可行。
兩次是相同的,例如兩個(gè)線程同時(shí)給total+1,如果不加鎖,就會(huì)兩個(gè)同時(shí)操作,導(dǎo)致total最終只+1,實(shí)際上是+2的
chrome調(diào)試面板看network,具體是哪個(gè)請(qǐng)求
本地和線上的環(huán)境對(duì)比
已解決,原因是文件名和模塊名重名導(dǎo)致的
注意:python3以后才支持yield from語(yǔ)法
import collections
def flatten(d, prefix="", sep="_"):
def _take_prefix(k, v, p):
if p:
yield from flatten(v, "{}{}{}".format(p, sep, k))
else:
yield from flatten(v, str(k))
if isinstance(d, dict):
for k, v in d.items():
if isinstance(v, str) or not isinstance(v, collections.Iterable):
if prefix:
yield "{}{}{}".format(prefix, sep, k), v
else:
yield k, v
elif isinstance(v, dict):
yield from _take_prefix(k, v, prefix)
elif isinstance(v, list):
for i in v:
yield from _take_prefix(k, i, prefix)
else:
pass
else:
pass
dic = {your dataset}
for key, value in flatten(dic):
print("{}: {}".format(key, value))
結(jié)果如下,應(yīng)該能拍平了
status: changed
dataset_id: 5a4b463c855d783af4f5f695
dataset_name: AE_E
dataset_label: 1- ADVERSE EVENTS - Not Analyzed
details_variables_variable_id: 5a4b4647855d783b494f9d3f
details_variables_variable_name: CPEVENT
details_variables_variable_label: CPEVENT
details_variables_status: changed
details_variables_details_r_type_new_value: unary
details_variables_details_r_type_old_value: factor
details_variables_message: Variable with different R Type
details_variables_variable_id: 5a4b4647855d783b494f9d25
details_variables_variable_name: CPEVENT2
details_variables_variable_label: CPEVENT2
details_variables_status: changed
details_variables_details_r_type_new_value: unary
details_variables_details_r_type_old_value: binary
details_variables_message: Variable with different R Type
details_variables_variable_id: 5a4b4647855d783b494f9d26
details_variables_variable_name: CP_UNSCHEDULED
details_variables_variable_label: CP_UNSCHEDULED
details_variables_status: changed
details_variables_details_r_type_new_value: undefined
details_variables_details_r_type_old_value: unary
details_variables_message: Variable with different R Type
details_variables_variable_id: 5a4b4647855d783b494f9d02
details_variables_variable_name: VISIT_NUMBER
details_variables_variable_label: VISIT_NUMBER
details_variables_status: changed
details_variables_details_r_type_new_value: unary
details_variables_details_r_type_old_value: integer
details_variables_message: Variable with different R Type
details_variables_variable_id: 5a4b4647855d783b494f9ccf
details_variables_variable_name: VISIT_NUMBER2
details_variables_variable_label: VISIT_NUMBER2
details_variables_status: changed
details_variables_details_r_type_new_value: unary
details_variables_details_r_type_old_value: binary
details_variables_message: Variable with different R Type
details_many_visits: None
針對(duì)你修改后的問(wèn)題, 再加個(gè)函數(shù)就搞定:
# 這個(gè)fuck_all函數(shù)比較特例, 完全是針對(duì)你要區(qū)分的dataset下面的N個(gè)變量信息這種需求
def fuck_all(dic, prefix="details_variables"):
lst = list(flatten(dic)) # flatten函數(shù)則比較通用,任何嵌套數(shù)據(jù)集都可以用它拍平
lines = []
top = {k: v for k, v in lst if not k.startswith(prefix)}
index = 0
for key, value in lst:
if not key.startswith(prefix):
continue
else:
if not lines:
lines.append(top.copy())
if key in lines[index].keys():
index += 1
lines.append(top.copy())
lines[index][key] = value
return lines
d = {your dataset}
for i in fuck_all(d):
print(i)
結(jié)果長(zhǎng)這樣,應(yīng)該是能滿(mǎn)足你需求了
{'status': 'changed', 'dataset_id': '5a4b463c855d783af4f5f695', 'dataset_name': 'AE_E', 'dataset_label': '1- ADVERSE EVENTS - Not Analyzed', 'details_many_visits': None, 'details_variables_variable_id': '5a4b4647855d783b494f9d3f', 'details_variables_variable_name': 'CPEVENT', 'details_variables_variable_label': 'CPEVENT', 'details_variables_status': 'changed', 'details_variables_details_r_type_new_value': 'unary', 'details_variables_details_r_type_old_value': 'factor', 'details_variables_message': 'Variable with different R Type'}
{'status': 'changed', 'dataset_id': '5a4b463c855d783af4f5f695', 'dataset_name': 'AE_E', 'dataset_label': '1- ADVERSE EVENTS - Not Analyzed', 'details_many_visits': None, 'details_variables_variable_id': '5a4b4647855d783b494f9d25', 'details_variables_variable_name': 'CPEVENT2', 'details_variables_variable_label': 'CPEVENT2', 'details_variables_status': 'changed', 'details_variables_details_r_type_new_value': 'unary', 'details_variables_details_r_type_old_value': 'binary', 'details_variables_message': 'Variable with different R Type'}
{'status': 'changed', 'dataset_id': '5a4b463c855d783af4f5f695', 'dataset_name': 'AE_E', 'dataset_label': '1- ADVERSE EVENTS - Not Analyzed', 'details_many_visits': None, 'details_variables_variable_id': '5a4b4647855d783b494f9d26', 'details_variables_variable_name': 'CP_UNSCHEDULED', 'details_variables_variable_label': 'CP_UNSCHEDULED', 'details_variables_status': 'changed', 'details_variables_details_r_type_new_value': 'undefined', 'details_variables_details_r_type_old_value': 'unary', 'details_variables_message': 'Variable with different R Type'}
{'status': 'changed', 'dataset_id': '5a4b463c855d783af4f5f695', 'dataset_name': 'AE_E', 'dataset_label': '1- ADVERSE EVENTS - Not Analyzed', 'details_many_visits': None, 'details_variables_variable_id': '5a4b4647855d783b494f9d02', 'details_variables_variable_name': 'VISIT_NUMBER', 'details_variables_variable_label': 'VISIT_NUMBER', 'details_variables_status': 'changed', 'details_variables_details_r_type_new_value': 'unary', 'details_variables_details_r_type_old_value': 'integer', 'details_variables_message': 'Variable with different R Type'}
{'status': 'changed', 'dataset_id': '5a4b463c855d783af4f5f695', 'dataset_name': 'AE_E', 'dataset_label': '1- ADVERSE EVENTS - Not Analyzed', 'details_many_visits': None, 'details_variables_variable_id': '5a4b4647855d783b494f9ccf', 'details_variables_variable_name': 'VISIT_NUMBER2', 'details_variables_variable_label': 'VISIT_NUMBER2', 'details_variables_status': 'changed', 'details_variables_details_r_type_new_value': 'unary', 'details_variables_details_r_type_old_value': 'binary', 'details_variables_message': 'Variable with different R Type'}
送佛送到西好了
from functools import reduce
import json
import pandas as pd
with open("your dataset file", "r") as fh:
dic = json.load(fh)
df = pd.DataFrame(reduce(lambda x, y: x + y, (fuck_all(i) for i in dic)))
df.to_csv("out.csv", index=False)
成品
參考一下這個(gè)答案吧: https://segmentfault.com/q/10...
你這邊直接運(yùn)行pyc,它的默認(rèn)搜索路徑和預(yù)加載模塊中都沒(méi)有AAA,所以不可能識(shí)別出來(lái)。正常的流程是運(yùn)行一個(gè)頂層腳本,它的同級(jí)目錄中有多個(gè)依賴(lài)的package
pip install netifaces -i http://pypi.douban.com/simple/
大概思路:
crontab里面添加這個(gè)xxx.py的文件,或者用supervisor管理這個(gè)進(jìn)程
然后xxx.py里面執(zhí)行subprocess.call('http-server')
不是很?chē)?yán)謹(jǐn),但這個(gè)思路能實(shí)現(xiàn)
看樣子你使用的是 python3 吧?
在 python2 里面可以直接使用 bytes(1);而在 python3 里面 你還可以使用 bytes(str(1), 'utf8')。手動(dòng)滑稽:)
RewriteRule ^(.*)$ index.php/$1 [QSA,NU,PT,L]
在偽靜態(tài)規(guī)則后面加上 [QSA,NU,PT,L] 配置完成
北大青鳥(niǎo)APTECH成立于1999年。依托北京大學(xué)優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國(guó)IT技能型緊缺人才,是大數(shù)據(jù)專(zhuān)業(yè)的國(guó)家
達(dá)內(nèi)教育集團(tuán)成立于2002年,是一家由留學(xué)海歸創(chuàng)辦的高端職業(yè)教育培訓(xùn)機(jī)構(gòu),是中國(guó)一站式人才培養(yǎng)平臺(tái)、一站式人才輸送平臺(tái)。2014年4月3日在美國(guó)成功上市,融資1
北大課工場(chǎng)是北京大學(xué)校辦產(chǎn)業(yè)為響應(yīng)國(guó)家深化產(chǎn)教融合/校企合作的政策,積極推進(jìn)“中國(guó)制造2025”,實(shí)現(xiàn)中華民族偉大復(fù)興的升級(jí)產(chǎn)業(yè)鏈。利用北京大學(xué)優(yōu)質(zhì)教育資源及背
博為峰,中國(guó)職業(yè)人才培訓(xùn)領(lǐng)域的先行者
曾工作于聯(lián)想擔(dān)任系統(tǒng)開(kāi)發(fā)工程師,曾在博彥科技股份有限公司擔(dān)任項(xiàng)目經(jīng)理從事移動(dòng)互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍(lán)懿科技有限責(zé)任公司從事總經(jīng)理職務(wù)負(fù)責(zé)iOS教學(xué)及管理工作。
浪潮集團(tuán)項(xiàng)目經(jīng)理。精通Java與.NET 技術(shù), 熟練的跨平臺(tái)面向?qū)ο箝_(kāi)發(fā)經(jīng)驗(yàn),技術(shù)功底深厚。 授課風(fēng)格 授課風(fēng)格清新自然、條理清晰、主次分明、重點(diǎn)難點(diǎn)突出、引人入勝。
精通HTML5和CSS3;Javascript及主流js庫(kù),具有快速界面開(kāi)發(fā)的能力,對(duì)瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁(yè)制作和網(wǎng)頁(yè)游戲開(kāi)發(fā)。
具有10 年的Java 企業(yè)應(yīng)用開(kāi)發(fā)經(jīng)驗(yàn)。曾經(jīng)歷任德國(guó)Software AG 技術(shù)顧問(wèn),美國(guó)Dachieve 系統(tǒng)架構(gòu)師,美國(guó)AngelEngineers Inc. 系統(tǒng)架構(gòu)師。