我发现import http.client
import urllib.request, urllib.parse, urllib.error
import json
def pushOver(title,message,url):
app_key = " app key "
user_key = " user key "
# connect with the pushover API Server
conn = http.client.HTTPSConnection("api.pushover.net:443")
# send a POST request in urlencoded json
conn.request("POST", "/1/message.json",
urllib.parse.urlencode({
"token": app_key,
"user": user_key,
"title": title,
"message": message,
"url": url,
}), { "content-type": "application/x-www-form-urlencoded" })
# any errors messages or other resonces?
conn.getresponse()
# app-specifict varables
pushOver('Doorbell', 'started', '')
print ("doorbell server started")
print ("Finished")
中的FileHandler
类不适用于正斜杠,但是,我在此站点上看到,正斜杠可以在Windows和Java上使用而不会出现问题。
我发现这是有问题的代码:
Logger
它失败并出现以下错误:
baseDir="C:/ets/phone/log/";
System.out.println("Basedir is:"+baseDir);
fh = new
FileHandler(baseDir+File.separator+"LogFile.%g.txt",1024000,5,true);
如果我将斜杠替换为 Basedir is:C:/ets/phone/log/
java.nio.file.NoSuchFileException: C:ets\phone\log\LogFile.0.txt.lck
at java.base/sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
at java.base/sun.nio.fs.WindowsFileSystemProvider.newFileChannel(Unknown Source)
at java.base/java.nio.channels.FileChannel.open(Unknown Source)
at java.base/java.nio.channels.FileChannel.open(Unknown Source)
at java.logging/java.util.logging.FileHandler.openFiles(Unknown Source)
at java.logging/java.util.logging.FileHandler.<init>(Unknown Source)
at java.logging/java.util.logging.FileHandler.<init>(Unknown Source)
at LogMe.<init>(LogMe.java:28)
at ETSServer.main(ETSServer.java:198)
Exception in thread "main" java.lang.NullPointerException
at java.base/java.util.Objects.requireNonNull(Unknown Source)
at java.logging/java.util.logging.Logger.addHandler(Unknown Source)
at LogMe.<init>(LogMe.java:40)
at ETSServer.main(ETSServer.java:198)
,则可以使用。这是错误吗?我应该举报吗?
File.seperator