我正在研究CS,我们对多态性有疑问,但我无法解读.这是一个例子:
public class AA{
public AA(){
foo();
}
private void foo() {
System.out.print("AA::foo ");
goo();
}
public void goo(){
System.out.print("AA::goo ");
}
}
public class BB extends AA{
public BB(){
foo();
}
public void foo(){
System.out.print("BB:foo ");
}
public void goo(){
System.out.print("BB::goo ");
}
public static void main(String[] args){
// Code goes here
}
}
Run Code Online (Sandbox Code Playgroud)
在void main中我添加以下行:
AA a = new BB();
Run Code Online (Sandbox Code Playgroud)
首先是AA构造函数打印AA:foo然后goo()将它发送到BB的goo,为什么呢?
简单的多态性,如"动物 - >猫/蜘蛛/狗"很容易理解,但是当谈到这一点时,我只是迷失了.你能给我一些如何阅读这段代码的提示吗?有什么规则?
编辑:没有@Override注释,因为这是考试中的问题.
使用Fuse.js我试图在 JS 对象中进行“多词”搜索,以获取包含所查找的每个词的记录。
我的数据结构如下(来自fuse.js):
[{
title: "The Lost Symbol",
author: {
firstName: "Dan",
lastName: "Brown"
}
}, ...]
Run Code Online (Sandbox Code Playgroud)
我的问题是我的设置适用于单字搜索(Brown例如),但不适用于更多(Dan Brown或Dan Brown Vinci)。
保险丝选项:
{
shouldSort: true,
matchAllTokens: true,
findAllMatches: true,
includeScore: true,
threshold: 0,
location: 0,
distance: 100,
maxPatternLength: 32,
minMatchCharLength: 1,
keys: [
"title",
"author.firstName",
"author.lastName"
]
}
Run Code Online (Sandbox Code Playgroud)
[{
title: "The Lost Symbol",
author: {
firstName: "Dan",
lastName: "Brown"
}
}, ...]
Run Code Online (Sandbox Code Playgroud)
{
shouldSort: true,
matchAllTokens: true,
findAllMatches: true, …Run Code Online (Sandbox Code Playgroud)我是ChartJS的新手,我对这个传奇有一些问题.我有一个简单的条形图,只有3个条形图,如:
<div class="x_panel">
<div class="x_title">
<h2>Bar graph</h2>
<ul class="nav navbar-right panel_toolbox" style="padding-left:5%">
<li>
<a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
</li>
<li>
<a class="close-link"><i class="fa fa-close"></i></a>
</li>
</ul>
<div class="clearfix"></div>
</div>
<div class="x_content">
<canvas id="mybarChart"></canvas>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
var mybarChart = new Chart(ctx, {
type: 'bar',
data: {
labels: [],
datasets: [{
label: '# of Votes',
backgroundColor: "#000080",
data: [80]
}, {
label: '# of Votes2',
backgroundColor: "#d3d3d3",
data: [90]
},
{
label: '# of Votes3',
backgroundColor: "#add8e6",
data: [45]
}]
},
options: …Run Code Online (Sandbox Code Playgroud) 我正在尝试以不同的语言在视图中本地化Carbon日期,但到目前为止还没有成功。
我从模型中检索日期并将它们发送到视图:
Route::get('/tables/setup', function(){
$now= Date::now('Europe/Paris');
$active_tasks = GanttTask::whereDate('start_date', '<', $now)
->whereDate('end_date', '>', $now)
->get();
return view('my_view', compact('active_tasks'));
});
Run Code Online (Sandbox Code Playgroud)
并且可以轻松地在“my_view”中显示它们:
@foreach($active_tasks as $active_task)
{{$active_task->start_date->format('l j F Y H:i:s')}} //Friday 26 January 2018 09:19:54
@endforeach
Run Code Online (Sandbox Code Playgroud)
但我无法以所需的语言呈现它们。
我尝试Carbon::setLocale('it');在路线或视图中添加没有效果。
编辑:
我的刀片调用中有轻微错误,{{$active_task->start_date->format('l j F Y H:i:s')}}而不是{{$active_task->format('l j F Y H:i:s')}}
tkinter当我使用运行时,我的程序运行良好PyCharm,当.exe使用pyinstaller 创建文件时,pyinstaller -i"icon.ico" -w -F script.py
没有任何错误。我将其粘贴script.exe到与我的文件夹相同的文件夹中script.py,并在运行它之后在步骤中认为subprocess它没有应答,因为我print在子进程行及其工作之前。
有人知道为什么吗?
这是带有子流程的行:
import subprocess
from subprocess import Popen, PIPE
s = subprocess.Popen([EXE,files,'command'],shell=True, stdout=subprocess.PIPE)
Run Code Online (Sandbox Code Playgroud)
编辑:
同样的问题:
s = subprocess.check_output([EXE,files,'command'],shell=True, stderr=subprocess.STDOUT)
Run Code Online (Sandbox Code Playgroud) 我读过这yield是一个生成器,但我无法真正理解它的含义,因为以下函数的输出完全相同:
def yieldFunction(number):
for x in range(number) :
yield x*2
def returnFunction(number):
output=[]
for x in range(number) :
output.append(x*2)
return output
for x in yieldFunction(10):
print(x)
print('-'*20)
for x in returnFunction(10):
print(x)
Run Code Online (Sandbox Code Playgroud)
输出:
0 2 4 6 8 10 12 14 16 18
0 2 4 6 8 10 12 14 16 18
在哪种情况下,其中一个优于另一个?
我实际上正在运行一个 Laravel 网站,我想在其中运行 Vuepress 文档部分。
由于有说明,安装 Vuepress 非常简单,开发服务器也是如此。
然而,当谈到将它集成为一个静态站点时,我对与 Laravel 的交互有点迷茫。
我的所有文档都位于docs我的 Laravel 应用程序根目录下的文件夹中。
我设法设置 Vuepress'config.js以将静态站点构建到另一个文件夹中。
base: '/docs/',
dest:'./public/docs',
Run Code Online (Sandbox Code Playgroud)
执行上述操作,将文档完全公开给网络(在公共文件夹中)。
但是,我正在寻找的是将它更精确地集成到 Laravel 中(使用我创建的中间件和路由)。
我正在尝试使用以下小脚本在 slack 的频道上发送一个熊猫数据帧:
import requests
URL = 'XXXXXX'
response = requests.post(
URL, data={dataframe}
)
Run Code Online (Sandbox Code Playgroud)
但是当我这样做时,我收到以下错误消息:'DataFrame' objects are mutable, thus they cannot be hashed!我也尝试将它作为 json 发送,但它对用户来说是不可读的。关于如何正确执行此操作的任何想法?谢谢!
我的数据框看起来如下:
Bot instance Current Potential profit Potential Profit 24h ago Change last 24h Volume 24h Volume Market
0 Biki - TECUSDT 21.69386074 USDT 21.60458081 USDT 0.08927993 USDT 0.84554375 USDT 28577.2565559176490500
1 Binance - XEMBTC -3.55974813 BTC -3.55514961 BTC -0.00459852 BTC 11.31867593 BTC 924.7716585800000000
2 Binance - XEM/ETH -15.38320177 ETH -15.32533185 ETH -0.05786992 ETH …Run Code Online (Sandbox Code Playgroud) python ×3
laravel ×2
bar-chart ×1
chart.js ×1
fuse.js ×1
ios ×1
java ×1
javascript ×1
pandas ×1
php-carbon ×1
polymorphism ×1
safari ×1
slack ×1
subprocess ×1
tkinter ×1
vue-devtools ×1
vue.js ×1
vuejs2 ×1
vuepress ×1