RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-222098

Александр's questions

Martin Hope
Александр
Asked: 2020-09-30 15:46:31 +0000 UTC

如何在 zeep 中为对象设置 xsi:type

  • 0

有一个用于 python 的肥皂客户端 - zeep。

使用它,我将数据传递给服务。问题是该服务要求您在包含所有内容的对象上指定 xsi:type 属性。

传递一个对象如下所示:

ambCase = {'data1':'value1',
           'data2':'value2'}
client = zeep.Client(wsdl=WSDL_Address)
result = client.service.MethodName(GUID, {'CaseDto':ambCase})

一切都会好的,只有 zeep 将默认对象类型设置为字符串(即 xsi:type = 'xsd:string'),但需要 'a:CaseAmb'。是否可以以某种方式设置传递对象的 xsi:type ?用文档翻遍了开发人员的网站,没有发现任何有价值的东西

python-2.x
  • 1 个回答
  • 10 Views
Martin Hope
Александр
Asked: 2020-09-13 20:46:37 +0000 UTC

在 python 2.7 中使用 unicode

  • 0

有一个代码片段:

self.city = str(rec[18])
self.country = str(rec[19]) + ' ' + str(rec[20])
self.street = str(rec[21])
self.house = str(rec[22])
self.flat = str(rec[23])
self.corps = str(rec[24])
self.full_addr = (str(rec[33]) if rec[33] is not None else (str(rec[34]) + ' ' + str(rec[35]))) + ' ' + \
                 str(rec[36]) + ' ' + \
                 self.house + ' ' + \
                 self.flat + \
                 ' ' + \     #ошибка здесь
                 self.corps

rec- 表示tuple与各种值混合,,, int-没关系,问题是就行unicode了None

' ' + \  # ошибка здесь

运行时,弹出错误:

File "client0.py", line 180, in initFromOtherRec
    ' ' + \
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-6: ordinal not in range(128)

而且我绝对不明白问题出在哪里,因为所有数据都被翻译成文本(并且文本格式相同)。

告诉我我哪里错了?

python
  • 1 个回答
  • 10 Views
Martin Hope
Александр
Asked: 2020-09-05 17:20:31 +0000 UTC

Python中列表中变量的成员资格

  • 1

有一个功能:

def checkSomething(var,varList):
    if var in varList:
        doSomeStuff()
    else:
        print("error")

传递的值使得 else 分支不应该被执行(例如 var=354, varList=[123,321,354])。在检查条件之前打印传递的值可以确认这一点,但是以某种难以理解的方式执行了 else 分支。

同时,如果您尝试在命令行上运行相同的东西(没有任何框架和库),那么一切都会正常运行(即不执行 else)

问题是,这怎么可能以及如何避免呢?

python
  • 2 个回答
  • 10 Views
Martin Hope
Александр
Asked: 2020-08-17 16:26:54 +0000 UTC

python中循环和迭代器的工作特点

  • 0

有一个用 python 2.7 编写的方法:

def findKeyInFnames(listOfDicts, someValue):
    for element in listOfDicts:
        if(element['someKey']==someValue):
            return element['someOtherKey']
        else:
            return 'Not found'
  • ListOfDicts- 具有一些值的类似字典列表
  • someValue- 执行搜索的键的某个值

每次调用该方法时,它必须从同一个字典中返回一个具有不同键的值。

问题是,无论键的值和它们的匹配项如何,它总是返回"Not found". 但是,如果你这样做:

def findKeyInFnames(listOfDicts, someValue):
    for element in listOfDicts:
        if(element['someKey']==someValue):
            return element['someOtherKey']

然后一切正常,并返回所需的值,除了而不是not found返回None。

为什么会发生这种情况,我怎样才能None从该方法返回我自己的消息?

python
  • 2 个回答
  • 10 Views
Martin Hope
Александр
Asked: 2020-12-12 18:15:52 +0000 UTC

xml 标记中的错误:解析 xml 时出错:格式不正确(无效标记)

  • 0

我写了一个简单的应用程序,它根据输入的值计算一个函数(所谓的分段函数)。

问题是,在设备上编译和运行时(运行 android 4.4 的平板电脑,该项目也分别为 android 4.4 创建),出现描述的错误,并带有指向描述应用程序表单的 xml 的链接。我从头开始重写了应用程序,通过复制粘贴内容重新创建了项目,清理并重建,但无济于事。

附加代码:xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.lab02a2andr_.MainActivity">

<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentTop="true"
    android:layout_alignParentStart="true"
    android:weightSum="1">

    <TextView
        android:text="введите Х:"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/textView3"
        android:layout_weight="0.03" />

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textPersonName"
        android:text="0.0"
        android:ems="10"
        android:id="@+id/editText" />

    <RadioGroup
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <RadioButton
            android:text="sin(x^2-3) x<=-1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/radioButton1" />

        <RadioButton
            android:text="(x+4)*x^2-3 -1<x<1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/radioButton3" />

        <RadioButton
            android:text="cos(sqrt(x)) x>=1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/radioButton2" />

    </RadioGroup>

    <CheckBox
        android:text="Удвоить"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/checkBox"
        android:layout_weight="0.03" />

    <Button
        android:text="Посчитать"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/button"
        android:layout_weight="0.03" />

    <TextView
        android:text="Ответ:"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.03"
        android:id="@+id/textView2" />
</LinearLayout>

主要活动:

package com.example.lab02a2andr_;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.TextView;


public class MainActivity extends AppCompatActivity {

private CheckBox cb;
private TextView tv2;
private RadioButton rb1,rb2,rb3;
private EditText et1;
private Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    cb=(CheckBox) findViewById(R.id.checkBox);
    tv2=(TextView) findViewById(R.id.textView2);
    rb1=(RadioButton) findViewById(R.id.radioButton1);
    rb2=(RadioButton) findViewById(R.id.radioButton2);
    rb3=(RadioButton) findViewById(R.id.radioButton3);
    et1=(EditText) findViewById(R.id.editText);
    button = (Button) findViewById(R.id.button);
    et1.setOnFocusChangeListener(new View.OnFocusChangeListener(){
        public void onFocusChange(View v, boolean hasFocus){
            if(!hasFocus){
                Calculate();
            }
        }
    });
    rb1.setOnClickListener(new View.OnClickListener(){
        public void onClick(View v){
            Calculate();
        }
    });
    rb2.setOnClickListener(new View.OnClickListener(){
        public void onClick(View v){
            Calculate();
        }
    });
    rb3.setOnClickListener(new View.OnClickListener(){
        public void onClick(View v){
            Calculate();
        }
    });
    cb.setOnClickListener(new View.OnClickListener(){
        public void onClick(View v){
            Calculate();
        }
    });
    button.setOnClickListener(new View.OnClickListener(){
        public void onClick(View v){
            Calculate();
        }
    });
}

public void Calculate(){
    String s1;
    double x,y=0;
    int var;

    s1=et1.getText().toString();
    x=Double.parseDouble(s1);


    if(rb1.isChecked()==true){
        var=1;
    }else if(rb2.isChecked()==true){
        var=2;
    }else if(rb3.isChecked()==true){
        var=3;
    }else{
        if(x<=-1) {
            var = 1;
            rb1.setChecked(true);
        }else if(x>=1){
            var=3;
            rb3.setChecked(true);
        }else{
            var=2;
            rb2.setChecked(true);
        }
    }

    switch (var){
        case 1:
            y=Math.sin(x*x-3);
            break;
        case 2:
            y=(x+4)*x*x-3;
            break;
        case 3:
            y=Math.cos(Math.sqrt(x));
            break;
    }

    if(cb.isChecked()==true){
        y*=2;
    }

    s1="Ответ: "+Double.toString(y);

}
}
android
  • 2 个回答
  • 10 Views
Martin Hope
Александр
Asked: 2020-10-04 22:12:25 +0000 UTC

从序列化的 json 对象中获取字典

  • 2

我在 python 中有一个 flask 函数

from flask import jsonify
def method1():
    result = {"jsonrpc": "2.0", ... }
    return jsonify(result)

接下来,我从另一个方法调用方法 1:

def method2():
    otherResult = method1()
    ...

在方法 2 中,我想获取结果的内容(来自方法 1)。我应该怎么做?问题是如果我尝试这样做:

response = otherResult['jsonrpc']

然后执行时出现如下错误:

TypeError: 'Response' object has no attribute '__getitem__'
python
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5