我在 Angular 中使用 d3 v4,下面是我的 d3graphcomponent.ts 文件。如果我在 python 本地服务器上运行它,它工作正常,但一旦我以角度运行它,它就会显示 Nest 不是一个函数
<script src="https://d3js.org/d3.v4.min.js"></script>我的index.html 中也有。
请评论有关所需文件和包的更多信息。
d3graphcomponent.ts
import { Component, OnInit, Input } from '@angular/core';
import * as d3 from 'd3-selection';
import * as d3Scale from 'd3-scale';
import * as d3Shape from 'd3-shape';
import * as d3Array from 'd3-array';
import * as d3Axis from 'd3-axis';
@Component({
selector: 'app-d3graph',
template: `
<h2>{{subtitle}}</h2>
<svg width="900" height="500"></svg>
`
})
export class D3graphComponent implements OnInit {
@Input() storeIntraffic: string;
@Input() dateForD3: string;
@Input() peopleInSumStr: …Run Code Online (Sandbox Code Playgroud) 我正在尝试连接 Hive 以在嵌入式/伪模式下使用 pyhive 获取一些表。下面是我使用过的代码
#!/usr/bin/env python
# coding: utf-8
from pyhive import hive
from TCLIService.ttypes import TOperationState
def mysql_connect(host, port, username):
conn = hive.Connection(host=host, port=port, username=username)
return conn.cursor()
cursor = mysql_connect("localhost", 50070, "hduser")
cursor.execute("show databases")
print_log(cursor)
Run Code Online (Sandbox Code Playgroud)
输出:我不知道为什么会收到此错误以及如何解决它
vaibhav@vaibhav-Lenovo-G570:~/Desktop/Python/Automation$ ./pyhive_test.py
Traceback (most recent call last):
File "./pyhive_test.py", line 9, in <module>
cursor = mysql_connect("localhost", 50070, "hduser")
File "./pyhive_test.py", line 6, in mysql_connect
conn = hive.Connection(host=host, port=port, username=username)
File "/usr/local/lib/python2.7/dist-packages/pyhive/hive.py", line 131, in __init__
self._transport.open()
File "/usr/local/lib/python2.7/dist-packages/thrift_sasl/__init__.py", line 80, in open …Run Code Online (Sandbox Code Playgroud) 我想在python中打印N叉树中从根到叶节点的所有路径。我有一个想法将其打印在二叉树中,但是在 N 进制中执行此操作不会给我正确的结果。
我在这里弹出并访问子节点列表中的每个节点,但不确定如何单独打印每个叶节点的路径。
class createnode:
def __init__(self,val):
self.data=val
self.child=[]
def traverse(root):
global path
if root.child:
while(len(root.child)>0):
x=root.child.pop(0)
path.append(x.data)
traverse(x)
else:
printarray(path)
def printarray(path):
print(path)
root = createnode(10)
root.child.append(createnode(2))
root.child.append(createnode(4))
root.child[0].child.append(createnode(15))
root.child[0].child.append(createnode(20))
root.child[0].child.append(createnode(25))
root.child[0].child.append(createnode(30))
root.child[1].child.append(createnode(45))
root.child[1].child.append(createnode(50))
root.child[1].child.append(createnode(55))
root.child[1].child.append(createnode(60))
path=[]
total_val=30
traverse(root)
Run Code Online (Sandbox Code Playgroud)
预期输出:
10、2、15
10, 2, 20
10、2、25
10、2、30
10、4、45
10、4、50
10、4、55
10、4、60
我想在我的 docker 容器上安装 ES(6.1.1),但引用了很多材料,我只看到默认情况下我能够下载最新版本 6.2.4,我不想要这个版本,因为我的代码中有某些包这不适用于最新版本。
ES下载链接 https://www.elastic.co/downloads/past-releases/elasticsearch-6-1-1
Docker 文件片段
RUN apt-get update && apt-get -y install apt-transport-https curl
RUN echo "deb https://artifacts.elastic.co/packages/6.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic.list
RUN apt-get update && sudo apt-get install elasticsearch
Run Code Online (Sandbox Code Playgroud)
正如你在这里看到的,它写的是 6.x,即使我通过复制下载链接将其更改为(ES 版本 6.1.1),我也会收到一些 buid 错误 404。
任何帮助,将不胜感激?
我正在尝试使用 STOMP 协议向我的 activemq 发送消息,但出现以下错误:
(limetray) Vaibhavs-MacBook-Air:Desktop vaibhav$ python receiver_topic.py heyhey
Unknown response frame type: ';activemq' (frame length was 11)
Unknown response frame type: '
' (frame length was 2)
Unknown response frame type: ')' (frame length was 2)
Unknown response frame type: '
' (frame length was 1)
Unknown response frame type: 'tcpnodelayenabled' (frame length was 20)
Unknown response frame type: 'sizeprefixdisabled' (frame length was 20)
Unknown response frame type: ' cachesize' (frame length was 11)
Unknown response frame …Run Code Online (Sandbox Code Playgroud) 我有一些信用卡号码,并希望通过以下规则验证它们.
►必须只包含数字(0-9)
►它可能有4个一组的数字,用一个连字符" - "分隔
►不得有4个或更多连续重复数字
►它可能包含没有任何空格的数字
输入:
5123-4567-8912-3456
61234-567-8912-3456
4123356789123456
5133-3367-8912-3456
输出:
有效
无效(因为卡号不分为4组相等)
有效
无效(连续33 33个数字重复4次)
我在这里试过,只有在最后包含连字符时才有效.有人可以给我一个正确的注册表.
编辑:
正则代码: ([0-9]{4}-){4}
输入要匹配 6244-5567-8912-3458
直到我把连字符放在最后才能匹配.
编辑
import re
import itertools
text="5133-3367-8912-3456"
print(len(text))
l=[(k, sum(1 for i in g)) for k,g in itertools.groupby(text)] #To calculate frequency of characters and later we can filter it with the condition v<=3 for checking the concurrency condition
if re.search(r'^[456]+',text) and len(text)==16 and re.search(r'[\d]',text) and all(v<=3 for k,v in l) and bool(re.search(r'\s',text)) is False …Run Code Online (Sandbox Code Playgroud) 我的文件名为“ Planning_Group_20180108.ind ”。我只想要Planning_Group。文件名也可以类似于Soldto_20180108,在这种情况下,输出应仅是Soldto。
不使用regex的解决方案是更可取的,因为对于尚未使用regex的人来说更容易阅读