- safari
- macos
- python
- 腾讯云
{"errorCode":-1,"errorMessage":"user code exception caught","stackTrace":"Traceback (most recent call last):\n File \"/var/user/index.py\", line 281, in main\n taskPool()\n File \"/var/user/index.py\", line 259, in taskPool\n check() # 每天对api做一次检查\n File \"/var/user/index.py\", line 247, in check\n respones = requests.get(url)\n File \"/var/lang/python3/lib/python3.6/site-packages/requests/api.py\", line 75, in get\n return request('get', url, params=params, **kwargs)\n File \"/var/lang/python3/lib/python3.6/site-packages/requests/api.py\", line 60, in request\n return session.request(method=method, url=url, **kwargs)\n File \"/var/lang/python3/lib/python3.6/site-packages/requests/sessions.py\", line 519, in request\n prep = self.prepare_request(req)\n File \"/var/lang/python3/lib/python3.6/site-packages/requests/sessions.py\", line 462, in prepare_request\n hooks=merge_hooks(request.hooks, self.hooks),\n File \"/var/lang/python3/lib/python3.6/site-packages/requests/models.py\", line 313, in prepare\n self.prepare_url(url, params)\n File \"/var/lang/python3/lib/python3.6/site-packages/requests/models.py\", line 387, in prepare_url\n raise MissingSchema(error)\nrequests.exceptions.MissingSchema: Invalid URL '?do=check': No schema supplied. Perhaps you meant http://?do=check?","statusCode":430}
- java
package LSQ;
class SuperClass{
int x;
SuperClass(){
x = 3;
System.out.println("in SuperClass:x=" + x);
}
void doSomething(){
System.out.println("in SuperClass.doSomething()");
}
}
class SubClass extends SuperClass{
int x;
SubClass(){
super();
x = 5;
System.out.println("in SubClass:x=" + x);
}
void doSomething(){
super.doSomething();
System.out.println("in SubClass.doSomething()");
System.out.println("super.x=" + super.x + " sub.x=" + x);
}
}
public class Star2{
public static void main(String[] args){
SubClass subC = new SubClass();
subC.doSomething();
}
}
- python
服务器:
python -m visdom.server -p 8091
ssh -L 18091:127.0.0.1:8097 name@xxx.xx.xxx.xx
本地:
python -m visdom.server
得到的是蓝屏界面
刷新后左下角出现
服务器端一直保持这个转台不再输出了
还有很奇怪的一点,就是我在本地上使用http://localhost:8091/也是蓝屏
- spring
这个代码是支持多坐标点击,怎么修改为只点一个坐标就可以!! document.onmousedown=function(ev){ var oEvent=ev||event; var cDiv=document.createElement('div'); var x = (oEvent.clientX+document.documentElement.scrollLeft + document.body.scrollLeft); var y = (oEvent.clientY+document.documentElement.scrollTop + document.body.scrollTop); cDiv.style="border-radius:50%;margin-left:-13px;margin-top:-13px;background:#f00;border:3px solid #ff0;position:absolute;width:20px;height:20px;z-index:100;"; cDiv.style.left=x+'px'; cDiv.style.top=y+'px'; document.body.appendChild(cDiv); var wrap = document.createElement("div"); wrap.style="width:100%;height:100%;border:1px solid red;background:#ff0;position:fixed;left:0;top:0;opacity:0.2;z-index:100;"; document.body.appendChild(wrap); var t_d = setTimeout(function(){ cDiv.parentNode.removeChild(cDiv); wrap.parentNode.removeChild(wrap); var cc = document.elementFromPoint(oEvent.clientX,oEvent.clientY); var t_cc = setInterval(function(){ cc.click(); },666); },1000);};
- java
- eclipse

- html5
- django
视图文件:
def new_topic(request):
if request.method != 'POST':
form = TopicForm()
print("not post")
else:
form = TopicForm(request.POST)
print("post")
if form.is_valid():
form.save()
return HttpResponseRedirect('http://www.baidu.com')
else:
print(form.errors.as_data()) # here you print errors to terminal
context = {'form': form}
return render(request, 'learning_logs/new_topic.html', context)
模板:
{% extends "learning_logs/base.html"%}
{%block content%}
<p>Add a new topic:</p>
<from action="{% url 'learning_logs:index'%}" method='post'>
{% csrf_token %}
{{form.as_p}}
<input type="submit" value="Submit" />
</from>
{%endblock content%}
浏览器按下按钮后没有获取到任何的包,请问如何解决
- linux
- centos
- 多彩生活
- 问答团队
- c语言
- c++
- apache
- android
- java
本人小白,刚学习蓝牙开发。我已经实现了蓝牙配对,对配对的设备进行连接,已经关闭了扫描而且利用了子线程进行连接,但还是不行。我用手机配对上了电脑,想把手机当做一个服务端就接收数据,但是bluetoothSocket.connect()没有用,请各位大佬看一下问题在哪。
我的活动
public class ThirdActivity extends AppCompatActivity {
private BluetoothAdapter bluetoothAdapter;
private BluetoothDevice bluetoothDevice;
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_third);
ButterKnife.bind(this);
//之前已经配对上了,获取到地址后接下来要对设备进行连接
Intent intent=getIntent();
String address = intent.getStringExtra("address");
bluetoothAdapter=BluetoothAdapter.getDefaultAdapter();
bluetoothDevice=bluetoothAdapter.getRemoteDevice(address);
textView5.setText("正在与"+bluetoothDevice.getName()+"进行连接。。。");
//按照一些例子写的连接子线程
ConnectThread connectThread = new ConnectThread(bluetoothDevice);
connectThread.start();
//按照一些例子写的接收服务子线程,但是也失败了
// AcceptThread acceptThread=new AcceptThread(bluetoothAdapter);
// acceptThread.start();
}
按照网上的例子写的连接子线程
public class ConnectThread extends Thread{
private BluetoothSocket bluetoothSocket;
private BluetoothDevice bluetoothDevice;
//这条是蓝牙串口通用的UUID
private final UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
public ConnectThread(BluetoothDevice device) {
this.bluetoothDevice=device;
try{
//图省事就直接获取了 this.bluetoothSocket=bluetoothDevice.createInsecureRfcommSocketToServiceRecord(uuid);
Log.e("connectthread", "获取socket");
}catch (IOException e){
e.printStackTrace();
bluetoothSocket=null;
}
}
@Override
public void run(){
//连接不成功,就一直循环
while(bluetoothSocket!=null) {
try {
bluetoothSocket.connect();
Log.e("connectthread", "连接成功");
} catch (IOException e) {
e.printStackTrace();
Log.e("connectthread", "连接失败");
}
if(bluetoothSocket.isConnected()){
try {
bluetoothSocket.close();
} catch (IOException e) {
e.printStackTrace();
}
break;
}
}
}
public void cancel() {
try {
bluetoothSocket.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
按照网上的例子写的接收连接线程——用了也失败了
public class AcceptThread extends Thread{
private BluetoothServerSocket bluetoothServerSocket;
private BluetoothSocket bluetoothSocket=null;
//这条是蓝牙串口通用的UUID
private final UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
public AcceptThread(BluetoothAdapter bluetoothAdapter) {
bluetoothServerSocket=null;
try {
this.bluetoothServerSocket=bluetoothAdapter.listenUsingRfcommWithServiceRecord("accept",uuid);
Log.e("accept", "获取服务socket");
}catch (IOException e){
e.printStackTrace();
Log.e("accept", "未获取服务socket");
}
}
@Override
public void run() {
while (bluetoothServerSocket!=null) {
try {
bluetoothSocket = bluetoothServerSocket.accept();
Log.e("accept","服务已连接" );
} catch (IOException e) {
e.printStackTrace();
Log.e("accept", "服务未连接");
}
if (bluetoothSocket!= null) {
try {
bluetoothServerSocket.close();
} catch (IOException e) {
e.printStackTrace();
}
break;
}
}
}
public void cancel() throws IOException {
bluetoothServerSocket.close();
}
}
我的logcat
说实话我对线程的理解以及socket的理解就不是很明白,如果有语法什么的低级错误也欢迎指出来,能够解决我的问题最好了
- c语言
- vue.js
- python
- 云计算
- python
- c语言
- jar
- 开发语言
- c++
#include <iostream>
#include <mutex>
#include <string>
#include <thread>
using namespace std;
std::mutex mu;
void share_print(string msg, int id)
{
mu.lock();
cout << msg << " " << id << endl;
mu.unlock();
}
void func_1()
{
for (int i = 0; i > -100; i--)
share_print("From func_1", i);
}
int main()
{
thread t1(func_1);
for (int i = 0; i < 100; i++)
share_print("From main", i);
t1.join();
}
代码如上,得到的结果如下,按照我的理解,主线程和t1线程分别调用cout函数,但是因为加了mutex锁,这个不应该是主线程和t1线程轮流输出吗,为什么会没有规律呢?谢谢了!!