小编Jim*_*tor的帖子

Python多处理 - 如何将kwargs传递给函数?

如何使用Python的多处理将字典传递给函数?文档:https://docs.python.org/3.4/library/multiprocessing.html#reference说传递字典,但我一直在

TypeError: fp() got multiple values for argument 'what'
Run Code Online (Sandbox Code Playgroud)

这是代码:

from multiprocessing import Pool, Process, Manager

def fp(name, numList=None, what='no'):
        print ('hello %s %s'% (name, what))
        numList.append(name+'44')

if __name__ == '__main__':

    manager = Manager()

    numList = manager.list()
    for i in range(10):
        keywords = {'what':'yes'}
        p = Process(target=fp, args=('bob'+str(i)), kwargs={'what':'yes'})
        p.start()
        print("Start done")
        p.join()
        print("Join done")
    print (numList)
Run Code Online (Sandbox Code Playgroud)

python multiprocessing kwargs

8
推荐指数
1
解决办法
8741
查看次数

如何从Angular 2响应中获取所有标题?

Chrome Dev Tools中的响应

我在Chrome开发工具中看到的响应标头与Angular 2在Chrome控制台中显示的响应标头不匹配.

仅显示内容类型

执行后只显示Content-Type标题:

this.http.get(tempUrl).map(res=>{
      console.log("csrf received");
      console.log(res);
})
Run Code Online (Sandbox Code Playgroud)

header response angular

4
推荐指数
1
解决办法
3990
查看次数

Ansible-尝试python3.5时找不到Virtualenv可执行文件

有没有办法解决无法找到正确的python版本的pip模块?关键问题似乎在于virtualenv_python

- name: Create venv and install requirements
  pip:
    requirements: /home/admin/dev/python/filepro/requirements.txt
    virtualenv: /home/admin/venvs/filepro
    virtualenv_python: python3.5
  tags:
    - venv
Run Code Online (Sandbox Code Playgroud)

错误:

Error message:
FAILED! => {"changed": false, "failed": true, "msg": "Failed to find required executable virtualenv"}
Run Code Online (Sandbox Code Playgroud)

/usr/bin/python3.5 是python 3.5所在的位置,我正在使用 Ansible 2.2.1.0

python virtualenv ansible

3
推荐指数
2
解决办法
2934
查看次数

Angular 2 - .http - 为什么我需要.subscribe到.map或.switchMap以使console.log工作?

我有一个基本组件,试图从中获取数据Params.但是我注意到如果我失踪了,我的调试代码通常不会起作用.subscribe().如果.subscribe()在此示例中已注释掉,则Got Params??不会打印到控制台.

this.route.params
  .switchMap((params: Params) =>{
    console.log("Got params??");
    console.log(params);
    // params['filename'])
    return 'cat';
  })
  .subscribe(data=>{
    console.log(data);
  })
Run Code Online (Sandbox Code Playgroud)

更多代码:

import { Component, OnInit } from '@angular/core';
import { Http } from '@angular/http';
import { Router, ActivatedRoute, Params } from '@angular/router';

import 'rxjs/add/operator/map';
import 'rxjs/add/operator/switchMap';


export class ParsedFileComponent implements OnInit {

  parsed: any;
  constructor(
    private http: Http,
    private route: ActivatedRoute 
  ) {      }
Run Code Online (Sandbox Code Playgroud)

似乎内部的代码.switchMap()没有被执行,除非它订阅了

dictionary observable angular

2
推荐指数
1
解决办法
1026
查看次数