我正在尝试使用Wikipedia API for python在维基百科页面中查看目录.这是我的代码.
>>> import wikipedia
>>> ny = wikipedia.page("New York")
>>> ny.sections
Run Code Online (Sandbox Code Playgroud)
但是我得到一个空列表[]
作为结果.当我进入页面检查时,我可以看到目录中有内容.除了这个之外,文档中说的所有其他内容似乎都有用.我是来自java背景的python的新手.
我正在尝试使用java程序连接到smartsheet api.最初我遇到了站点证书的问题,该证书通过将其添加到java密钥库来解决.现在,当我尝试运行我的代码时,我收到以下错误.
Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:144)
at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:955)
at org.apache.http.impl.client.HttpClients.createDefault(HttpClients.java:58)
at com.smartsheet.api.internal.http.DefaultHttpClient.<init>(DefaultHttpClient.java:64)
at com.smartsheet.api.SmartsheetBuilder.build(SmartsheetBuilder.java:203)
at SmartsheetConnection.main(SmartsheetConnection.java:13)
Run Code Online (Sandbox Code Playgroud)
这是我的代码(我按照他们的文档).
import com.smartsheet.api.*;
import com.smartsheet.api.models.*;
import com.smartsheet.api.models.enums.*;
import com.smartsheet.api.oauth.*;
public class SmartsheetConnection {
public static void main(String[] args) throws SmartsheetException {
// Set the access token.
Token token = new Token();
token.setAccessToken("foo");
Smartsheet smartsheet = new SmartsheetBuilder().setAccessToken(token.getAccessToken()).build();
}
}
Run Code Online (Sandbox Code Playgroud)
投掷错误的行是(第144行)
@Deprecated
public static final X509HostnameVerifier ALLOW_ALL_HOSTNAME_VERIFIER
= AllowAllHostnameVerifier.INSTANCE;
Run Code Online (Sandbox Code Playgroud)
但我不知道该怎么做.我正在使用maven来获取依赖项.它与Apache HttpComponents的版本有关吗?
这是pom.xml
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target> …
Run Code Online (Sandbox Code Playgroud) 我在运行一些代码时遇到了一个奇怪的错误.这是一个展示相同的简单版本.
public class DateTest {
public static void main(String[] args) {
LocalDate decLast = LocalDate.of(2015, 12, 31);
LocalDate novLast = LocalDate.of(2015, 11, 30);
LocalDate octLast = LocalDate.of(2015, 10, 31);
System.out.println(decLast+" "+novLast+" "+octLast);
System.out.println(decLast.format(DateTimeFormatter.ofPattern("dd M YY"))+" "
+novLast.format(DateTimeFormatter.ofPattern("dd M YY"))+" "
+octLast.format(DateTimeFormatter.ofPattern("dd M YY")));
}
}
Run Code Online (Sandbox Code Playgroud)
这返回了以下结果
2015-12-31 2015-11-30 2015-10-31
31/12/16 30/11/15 31/10/15
Run Code Online (Sandbox Code Playgroud)
不知何故,2015年12月31日被转换为2016年12月31日.我写了一个for循环来做同样的不同年份,并发现多年来存在变化.12月26日以下的任何日期都不存在该错误.这是一个错误还是我错过了什么?
我对python很新.我正在使用Ubuntu 14.04并安装了python 2.7.6和python 3.4.0.我试图安装BeautifulSoup,但不能,因为我得到一个错误说
The program 'pip' is currently not installed.
Run Code Online (Sandbox Code Playgroud)
我发现它与python 3.4捆绑在一起.我尝试使用sudo easy_install pip
stackoverflow上的另一个问题中提到的pip进行安装.但这会产生错误sudo: easy_install: command not found
.
问题是什么?
我试着输入这个命令
mkdir -p lol\hit\xx
Run Code Online (Sandbox Code Playgroud)
但我收到一条错误消息
mkdir: Parameter cannot be processed because the parameter name 'p' is ambiguous.
Run Code Online (Sandbox Code Playgroud)
我在线跟踪教程,据此,不应该有任何错误.这背后的原因是什么?
我试图解析以下时间戳字符串03-feb-2014 13:16:31
使用java.time
但它抛出一个错误.这是我的代码.
String timestamp = "03-feb-2014 13:16:31";
DateTimeFormatter format;
DateTimeFormatterBuilder formatBuilder = new DateTimeFormatterBuilder();
formatBuilder.parseCaseInsensitive();
formatBuilder.append(DateTimeFormatter.ofPattern("dd-MMM-YYYY HH:mm:ss"));
format = formatBuilder.toFormatter();
LocalDateTime localdatetime = LocalDateTime.parse(timestamp, format);
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误.
Exception in thread "main" java.time.format.DateTimeParseException: Text '03-feb-2014 13:16:31' could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor: {DayOfMonth=3, MonthOfYear=2, WeekBasedYear[WeekFields[SUNDAY,1]]=2014},ISO resolved to 13:16:31 of type java.time.format.Parsed
at java.time.format.DateTimeFormatter.createError(DateTimeFormatter.java:1920)
at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1855)
at java.time.LocalDateTime.parse(LocalDateTime.java:492)
at com.target.util.CntrlmProcessor.main(CntrlmProcessor.java:24)
Caused by: java.time.DateTimeException: Unable to obtain LocalDateTime from TemporalAccessor: {DayOfMonth=3, MonthOfYear=2, WeekBasedYear[WeekFields[SUNDAY,1]]=2014},ISO resolved to 13:16:31 …
Run Code Online (Sandbox Code Playgroud) 我使用Spring启动创建了一个REST API.我使用gradle作为我的构建工具.我已经使用嵌入式容器测试了应用程序,它运行正常.我可以访问我的申请表localhost:8080/foo/bar
.
现在我已将它部署到tomcat而没有任何错误.
Mar 17, 2016 1:58:47 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /usr/local/apache-tomcat-7.0.65/webapps/foo.war
Mar 17, 2016 1:58:48 PM org.apache.catalina.startup.TldConfig execute
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Mar 17, 2016 1:58:48 PM org.apache.catalina.startup.HostConfig deployWAR …
Run Code Online (Sandbox Code Playgroud) 我想解决一个问题.但是程序控制进入if语句,即使我检查的数字都是相同的,也不应该发生.是什么原因?
static int lonelyinteger(int[] a) {
Integer[] b=new Integer[a.length];
for(int i=0;i<a.length;i++){
b[i]=new Integer(a[i]);
}
int val=0;
Arrays.sort(b);
boolean flag=false;
for(int i=0;i<a.length-2;i+=2)
if (b[i]!=b[i+1]){
val=b[i];
flag=true;
break;
}
if(flag==true)
return val;
else
return b[a.length-1];
Run Code Online (Sandbox Code Playgroud) java ×4
datetime ×2
java-8 ×2
java-time ×2
python-3.x ×2
easy-install ×1
gradle ×1
java-7 ×1
parsing ×1
pip ×1
powershell ×1
python-2.7 ×1
python-3.4 ×1
spring-boot ×1
tomcat ×1
windows ×1