我有一个这样的项目结构:
src (sources root)
---main
-------java (sources root)
-----------com
--------------requests
----------------------File1.java (needs to be package com.requests)
----------------------File2.java (needs to be package com.requests)
----------------------File3.java (needs to be package com.requests)
--------------things
--------------util
--------------web
-------resources
----------------images
-------webapp
-------------WEB-INF
--------------------classes
---------------------------com
------------------------------requests
------------------------------things
------------------------------util
------------------------------web
---------------------lib
Run Code Online (Sandbox Code Playgroud)
但是,File1.java
,File2.java
并且File3.java
似乎没有被识别为 Java 文件,我无法编译它们:
为什么?我如何解决它?
我有一个<form>
在vue
。我将该表单发送到服务器,获取 JSON 响应,然后将其打印到控制台。它工作正常。
但是,我需要获取该 JSON 响应并将其显示在另一个页面上。例如,我有两个.vue
文件:GetAnimal.vue
具有表单并从 API 检索动物数据的文件和DisplayAnimal.vue
显示动物数据的文件。我需要将响应动物数据从GetAnimal.vue
到DisplayAnimal.vue
。
获取Animal.vue:
<template>
<form v-on:submit.prevent="getAnimal()">
<textarea v-model = "animal"
name = "animal" type="animal" id = "animal"
placeholder="Enter your animal here">
</textarea>
<button class = "custom-button dark-button"
type="submit">Get animal</button>
</form>
</template>
Run Code Online (Sandbox Code Playgroud)
<script>
import axios from 'axios';
export default {
name: 'App',
data: function() {
return {
info: '',
animal: ''
}
},
methods: {
getAnimal: function() {
axios
.get('http://localhost:8088/animalsapi?animal=' …
Run Code Online (Sandbox Code Playgroud) 我有一个vue
包含方法的组件,该方法包含尝试推送到另一个vue
组件的路由器推送:
获取Animal.vue:
...
this.$router.push({
name: "/viewanimal",
});
...
Run Code Online (Sandbox Code Playgroud)
我有这个路由器的映射:
路由器.js:
{
path: "/viewanimal",
component: () => import('./views/DisplayAnimal.vue')
},
{
path: "/getanimal",
component: () => import('./views/GetAnimal.vue')
}
Run Code Online (Sandbox Code Playgroud)
然而,当里面的代码GetAnimal.vue
被执行时,我在控制台中得到了这个:
我被定向到http://localhost:8080/
.
我也试过
...
this.$router.push({
name: "viewanimal",
});
...
Run Code Online (Sandbox Code Playgroud)
但它也不起作用。
编辑:
我试过: router.js:
{
path: "/viewanimal",
name: "viewanimal",
component: () => import('./views/DisplayAnimal.vue')
},
{
path: "/getanimal",
name: "getanimal",
component: () => import('./views/GetAnimal.vue')
}
Run Code Online (Sandbox Code Playgroud)
获取Animal.vue:
console.log("this.animal: " + JSON.stringify(this.animal)); //displays good JSON …
Run Code Online (Sandbox Code Playgroud) 我正在尝试安装html5lib
.起初我试图安装最新版本(8或9个9),但它与我的BeautifulSoup发生冲突,所以我决定尝试更老的版本(0.9999999,7 个9).我安装了它,但是当我尝试使用它时:
>>> with urlopen("http://example.com/") as f:
document = html5lib.parse(f, encoding=f.info().get_content_charset())
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
Traceback (most recent call last):
File "<pyshell#11>", line 2, in <module>
document = html5lib.parse(f, encoding=f.info().get_content_charset())
File "C:\Python\Python35-32\lib\site-packages\html5lib\html5parser.py", line 35, in parse
return p.parse(doc, **kwargs)
File "C:\Python\Python35-32\lib\site-packages\html5lib\html5parser.py", line 235, in parse
self._parse(stream, False, None, *args, **kwargs)
File "C:\Python\Python35-32\lib\site-packages\html5lib\html5parser.py", line 85, in _parse
self.tokenizer = _tokenizer.HTMLTokenizer(stream, parser=self, **kwargs)
File "C:\Python\Python35-32\lib\site-packages\html5lib\_tokenizer.py", line 36, in __init__
self.stream = HTMLInputStream(stream, **kwargs)
File "C:\Python\Python35-32\lib\site-packages\html5lib\_inputstream.py", line 151, in HTMLInputStream
return HTMLBinaryInputStream(source, **kwargs) …
Run Code Online (Sandbox Code Playgroud) 我有一Client
堂课。在那个类里面有一个数组losses
。首先,我创建并填充客户端clientsColl
数组。然后对于该数组中的每个客户端,我填充它的losses
数组。
然后我尝试打印调试losses
每个客户端的第一个元素。但是,它不起作用并Property let procedure not defined and property get procedure did not return an object
出现错误。
而同一时间,如果我只是尝试显示的第一个元素losses
为第一个客户,没有任何周期,它工作正常:
Dim clientsColl() As Client
clientsColl = getClients(dataWorkbook)
Dim clientCopy As Variant
Debug.Print "first: " & clientsColl(1).getLosses(1) 'works fine
For Each clientCopy In clientsColl
Debug.Print "in for each: " & clientCopy.getLosses(1) 'error here
Next
Run Code Online (Sandbox Code Playgroud)
在Client
课堂上:
Public Property Get getLosses()
getLosses = losses
End Property
Private losses() As …
Run Code Online (Sandbox Code Playgroud) 这个简单的代码:
s = "it's a nice day..."
s = shlex.split(s)
Run Code Online (Sandbox Code Playgroud)
会导致ValueError: No closing quotation
错误:
Traceback (most recent call last):
File "<pyshell#27>", line 1, in <module>
s = shlex.split(s)
File "C:\Python\Python35-32\lib\shlex.py", line 273, in split
return list(lex)
File "C:\Python\Python35-32\lib\shlex.py", line 263, in __next__
token = self.get_token()
File "C:\Python\Python35-32\lib\shlex.py", line 90, in get_token
raw = self.read_token()
File "C:\Python\Python35-32\lib\shlex.py", line 166, in read_token
raise ValueError("No closing quotation")
ValueError: No closing quotation
Run Code Online (Sandbox Code Playgroud)
我认为'
是错的。我该如何处理?我从文件中读取了这一行,所以我不能\
在每个引号或其他东西之前输入。
我有这个简单的课程:
测试.java:
import javafx.animation.FadeTransition;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import javafx.util.Duration;
public class Test extends Application {
@Override
public void start(Stage stage) throws Exception {
Pane pane = new Pane();
Button testButton = new Button("Test");
testButton.setStyle("-fx-background-color: green;");
pane.getChildren().add(testButton);
pane.setStyle("-fx-background-color: red;");
FadeTransition transition = new FadeTransition(Duration.millis(5000), pane);
transition.setFromValue(1.0);
transition.setToValue(0.0);
transition.setCycleCount(Timeline.INDEFINITE);
transition.setAutoReverse(true);
transition.play();
Scene scene = new Scene(pane, 500, 500);
stage.setMinWidth(500);
stage.setMinHeight(500);
stage.setTitle("Test");
stage.setResizable(false);
stage.setScene(scene);
stage.show();
}
}
Run Code Online (Sandbox Code Playgroud)
它看起来像这样:
然而当它消失时,它就变成了这样:
如何使淡入淡出过渡仅影响红色背景而不影响绿色按钮?
所以它看起来像这样:
我正在尝试从wired.com 获取文章。通常他们的文章内容是这样的:
<article itemprop="articleBody">
<p>Some text</p>
<p>Next text</p>
<p>...</p>
<p>...</p>
</article>
Run Code Online (Sandbox Code Playgroud)
或者像这样:
<article itemprop="articleBody">
<div class="listicle-captions marg-t...">
<p></p>
</div>
</article>
Run Code Online (Sandbox Code Playgroud)
所以我想要如果页面是类型 1,<p>
和<h>
被提取,而如果页面是类型 2 - 做其他事情。所以,如果<p>
and<h>
是 的直接后代<article>
,那么它是类型 1。我尝试了下面的代码,它查找<p>
and<h>
并打印出标签名称。问题是,这recursive="False"
似乎没有帮助,因为在类型 2 页面上测试时,它找到了标签,而它不应该找到(我希望得到一个NonType
对象)。
import urllib.request
from bs4 import BeautifulSoup
import datetime
import html
import sys
articleUrl="https://www.wired.com/2016/07/greatest-feats-inventions-100-years-boeing/"
soupArticle=BeautifulSoup(urllib.request.urlopen(articleUrl), "html.parser")
articleBody=soupArticle.find("article", {"itemprop":"articleBody"})
articleContentTags=articleBody.findAll(["h1", "h2","h3", "p"], recursive="False")
for tag in articleContentTags:
print(tag.name)
print(tag.parent.encode("utf-8"))
Run Code Online (Sandbox Code Playgroud)
为什么不起作用?
PS另外,在这种特殊情况下使用findAll
和findChildren
一般情况下有区别吗?这两个在我看来是一样的。。
我想使用http://overpass-turbo.eu/获取纽约市的所有街道。我试过这个:
[out:json]; area[name = "New York"]; (node(area)[highway=street]; ); out;
Run Code Online (Sandbox Code Playgroud)
然而它返回
{
"version": 0.6,
"generator": "Overpass API 0.7.55.1009 5e627b63",
"osm3s": {
"timestamp_osm_base": "2019-11-13T19:26:03Z",
"timestamp_areas_base": "2019-11-13T18:05:02Z",
"copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL."
},
"elements": [
]
}
Run Code Online (Sandbox Code Playgroud)
没有元素。然而这个查询:
[out:json]; area[name = "New York"]; ( node(area)[amenity=cinema]; node(area)[highway=street]; ); out;
Run Code Online (Sandbox Code Playgroud)
为了获取街道和电影院,可以使用:
{
"version": 0.6,
"generator": "Overpass API 0.7.55.1009 5e627b63",
"osm3s": {
"timestamp_osm_base": "2019-11-13T19:29:02Z",
"timestamp_areas_base": "2019-11-13T18:05:02Z",
"copyright": "The data included …
Run Code Online (Sandbox Code Playgroud) 我有这两个文件:
测试.js:
const jsdom = require("jsdom");
const hello = () => {
console.log("hello!");
};
module.exports = {
hello
};
Run Code Online (Sandbox Code Playgroud)
和
服务器.js:
const hello = require('./stuff/test');
hello.hello();
Run Code Online (Sandbox Code Playgroud)
目录结构:
myprojectfolder
backend
src
stuff
test.js
server.js
Run Code Online (Sandbox Code Playgroud)
当我运行时,server.js
我收到ReferenceError: TextEncoder is not defined
错误:
/home/myusername/projects/myprojectfolder/node_modules/whatwg-url/lib/encoding.js:2
const utf8Encoder = new TextEncoder();
^
ReferenceError: TextEncoder is not defined
Run Code Online (Sandbox Code Playgroud)
如果我const jsdom = require("jsdom");
从 中删除行test.js
,server.js
则运行正常并且没有任何错误(输出hello
)。
为什么会发生这种情况以及如何修复它(同时仍然能够jsdom
在内部导入和使用test.js
?)。
javascript ×3
java ×2
python ×2
vue.js ×2
vuejs2 ×2
web-scraping ×2
arrays ×1
excel ×1
html5lib ×1
javafx ×1
jsdom ×1
json ×1
node.js ×1
overpass-api ×1
python-3.x ×1
shlex ×1
vba ×1
vue-router ×1