小编spe*_*123的帖子

使用 GET 请求发送数组

我正在从 Javascript 向 Python 发出获取请求。我正在尝试传递一个二维数组,比如

[["one", "two"],["foo", "bar"]]
Run Code Online (Sandbox Code Playgroud)

这是我目前正在尝试的,但它不起作用。

因此,在我的 javascript 中,我有一个与上面的数组类似的数组,然后像这样传递它

var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", "http://192.67.64.41/cgi-bin/hi.py?array=" + myArray, false );
xmlHttp.send( null );
Run Code Online (Sandbox Code Playgroud)

然后在 python 中我得到这样的结果

import cgi
form = cgi.FieldStorage()
array = form.getvalue("array")
Run Code Online (Sandbox Code Playgroud)

但如果我这样做的话,结果并不正确,在 python 中

print array[0]
#I get -> "o"
print array[1]
#I get -> "n"
print array[2]
#I get -> "e"
Run Code Online (Sandbox Code Playgroud)

等等,但如果我想要的是

print array[0]
#output -> ["one", "two"]
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

谢谢

javascript python arrays get http

6
推荐指数
1
解决办法
3万
查看次数

spring-boot-maven-plugin:build-image 因 400 Bad Request 失败

我正在尝试使用 spring-boot-maven-plugin:build-image 目标为我的基本 Spring Boot 应用程序构建一个 docker 镜像。

它失败并出现以下错误:

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.4.0-M2:build-image (default-cli) on project spring-docker: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:2.4.0-M2:build-image failed: **Docker API call to 'localhost/v1.24/containers/eaaba1e2a727547ae53df3c1f7c4420ba821914b4392ea12ff47326ee03eeaa5/start' failed with status code 400 "Bad Request"** -> [Help 1]
Run Code Online (Sandbox Code Playgroud)

我已经尝试过Spring Boot 2.3.3.RELEASE2.4.0-M2,我得到了同样的错误。

我在 Windows 10 机器上运行 Docker 桌面。

$ docker version

**Client: Docker Engine - Community
 Version:           19.03.12
 API version:       1.40**
 Go version:        go1.13.10
 Git commit:        48a66213fe
 Built:             Mon Jun 22 15:43:18 2020
 OS/Arch:           windows/amd64 …
Run Code Online (Sandbox Code Playgroud)

maven docker spring-boot

6
推荐指数
1
解决办法
547
查看次数

保存base64图像python

我正在尝试使用 Base64 编码的 python 保存图像。这里的字符串太大无法发布,但这里是图像

在此处输入图片说明

当 python 接收到最后 2 个字符时,==虽然字符串没有格式化,所以我这样做

import base64
data = "data:image/png;base64," + photo_base64.replace(" ", "+")
Run Code Online (Sandbox Code Playgroud)

然后我这样做

imgdata = base64.b64decode(data)
    filename = 'some_image.jpg'  # I assume you have a way of picking unique filenames
    with open(filename, 'wb') as f:
            f.write(imgdata)
Run Code Online (Sandbox Code Playgroud)

但这会导致此错误

Traceback (most recent call last):
  File "/var/www/cgi-bin/save_info.py", line 83, in <module>
    imgdata = base64.b64decode(data)
  File "/usr/lib64/python2.7/base64.py", line 76, in b64decode
    raise TypeError(msg)
TypeError: Incorrect padding
Run Code Online (Sandbox Code Playgroud)

我还打印出字符串的长度,一旦data:image/png;base64,添加和spaces替换,+它的长度34354为损坏的。 …

python image base

5
推荐指数
1
解决办法
1万
查看次数

将链接元素 <a> 添加到段落 <p> Javascript

我正在尝试将链接添加到已经有一些文本的段落中,但是当我尝试时,这只是添加了链接元素的文本而不是实际链接。href 或<a>标签。这是 html

<div id="main_div"></div>
Run Code Online (Sandbox Code Playgroud)

这是 Javascript

var temp_link = document.createElement("A");
temp_link.href = "http://test.com";
temp_link.target = '_blank';

var par = document.createElement("P");
par.innerHTML = "some text: " + temp_link;

<!--I have also tried this line below -->
<!--    par.insertAdjacentHTML('beforeend', '<div><a>' + url +'</a></div>' -->);

document.getElementById("main_div").appendChild(par);
Run Code Online (Sandbox Code Playgroud)

我已经尝试了上面 javascript 中的两件事,包括当前运行的内容和注释掉的行,都没有附加链接,他们只是添加了我包含的文本JSFiddle

如何添加它以便<a>链接?

html javascript css jquery

4
推荐指数
1
解决办法
4105
查看次数

设置视图可见性消失保留其他视图

我有一些看起来像这样的 xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    <TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="text"
    android:id="@+id/Text"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:textSize="34sp"/>
   <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Call"
    android:id="@+id/callText"
    android:layout_below="@+id/Text"
    android:layout_alignLeft="@+id/Text"
    android:layout_alignStart="@+id/Text"
    />

 />
Run Code Online (Sandbox Code Playgroud)

现在我想将带有 id 的 TextView 设置Text为 GONE,但是当我这样做时,带有 id 的 TextViewcallText也会消失,我想要的是设置Text为 GONE,然后向上callText移动并保持可见?

我怎么能这样做呢?

谢谢

java xml android

1
推荐指数
1
解决办法
991
查看次数

X 轴标签被图形截断 - Python Matplotlib

我在我的 python 脚本中有这个

date_list = ["01/11/2015", "01/12/2015", "01/13/2015", "01/14/2015"]
plt.plot([1,2,3,4], [2,4,6,8])
plt.xticks([1,2,3,4], date_list)
locs, labels = plt.xticks()
plt.setp(labels, rotation=45)
plt.savefig('test.pdf')
Run Code Online (Sandbox Code Playgroud)

它产生了一个看起来像这样的图表

在此处输入图片说明

正如你所看到的 x 标签被切断,这不是我没有完全展开图表,我已经尝试过,它仍然被切断。我怎样才能在图表上获得整个标签?

谢谢

python matplotlib

1
推荐指数
1
解决办法
6067
查看次数

标签 统计

python ×3

javascript ×2

android ×1

arrays ×1

base ×1

css ×1

docker ×1

get ×1

html ×1

http ×1

image ×1

java ×1

jquery ×1

matplotlib ×1

maven ×1

spring-boot ×1

xml ×1