RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

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

Каролина's questions

Martin Hope
Каролина
Asked: 2022-01-03 02:40:22 +0000 UTC

Java中带有复制构造函数的深度复制构造函数[关闭]

  • 1
关闭 这个问题是题外话。目前不接受回复。

该问题是由不再复制的问题或错字引起的。虽然类似问题可能与本网站相关,但该问题的解决方案不太可能帮助未来的访问者。通常可以通过在发布问题之前编写和研究一个最小程序来重现问题来避免此类问题。

1 年前关闭。

改进问题

该类Cat有 3 个构造函数:

public class Cat  {
    private double originWeight;
    private double weight;

    private double minWeight;
    private double maxWeight;

    private double weightFoodEaten;

    private static int count = 0;

    public static final int COUNT_CAT_EYES = 2;
    public static final double MIN_CAT_WEIGHT = 1000.0;
    public static final double MAX_CAT_WEIGHT = 9000.0;

    private Color catColor;

    public Cat() {
        weight = 1500.0 + 3000.0 * Math.random();
        originWeight = weight;
        minWeight = 1000.0;
        maxWeight = 9000.0;
        weightFoodEaten = 0;
        count++;
    }

    public Cat(double weight) {
        this();
        this.weight = weight;
    }

    public Cat(Cat n) {
        weight = n.weight;
        originWeight = n.originWeight;
        minWeight = n.minWeight;
        maxWeight = n.maxWeight;
        weightFoodEaten = n.weightFoodEaten;
        count++;
    }
}

构造函数 Cat(Cat n)是构造函数的副本Cat(double weight)。

在类Test_2中,我首先创建了一个构造函数对象Cat(double weight),然后创建了它的副本Cat(Cat n)。

告诉我为什么我不能创建副本。我需要使用类中的复制构造函数准确地创建一个副本。

public class Test_2 {
    public static void main(String[] args) {
        
        Cat bb = new Cat(5000);
        Сat cat7 = new Cat(Cat bb);
    }
}
java
  • 1 个回答
  • 10 Views
Martin Hope
Каролина
Asked: 2020-05-04 23:02:30 +0000 UTC

通过代理 127.0.0.1 注销在浏览器中不起作用

  • 0

我使用 jmeter 进行测试,因此有必要在该程序的测试脚本记录器中记录操作。记录是通过指定端口、代理服务器和浏览器本身来完成的(即您浏览页面并记录操作)。我按照手册和YouTube上的视频进行了所有设置,但是没有一个浏览器通过代理127.0.0.1和8080或8888等不同的端口号访问Internet。告诉我可以做什么。网上有人建议清除缓存,关闭所有插件,检查hosts文件中是否有127.0.0.1地址。我检查了一切。没有什么帮助。

在此处输入图像描述

我还取消选中“所有协议的一个代理服务器”框 - 也没有帮助在此处输入图像描述

以下是浏览器显示的屏幕截图: 在此处输入图像描述

Ping 到 127.0.0.1 工作正常,没有丢包

proxy
  • 1 个回答
  • 10 Views
Martin Hope
Каролина
Asked: 2020-04-06 03:26:06 +0000 UTC

为什么 Python 字典函数可以在不调用它们的情况下工作

  • 0

我正在为我在 tkinter 和 python 中的需要编写一个程序。单击按钮时,getParameters 函数应在循环中将数组的值与字典进行比较。如果数组的某个值与字典的键匹配,则从字典中调用该键的函数。但事实上,程序的工作方式是程序调用字典中的所有函数,而不需要循环参与。请告诉我如何解决它。请不要注意程序界面稀少的事实。这是故意这样做的,以便可以看到问题的本质。

 from tkinter import *
    win2 = Tk()

    def receive_of_word():
        param = "55"
        return param

    def word(param):
        x = 5
        print(x)
        return x

    def word_2(param):
        y = 10
        print(y)
        return y

    def getParameters():
        ex ={
          "xx": word(receive_of_word()),
          "yy": word_2(receive_of_word()),
          }

        a = ["xx", "zz"]

        for i in a:
            if i in ex:
                ex[i]


    win2.title('Программа')
    win2.minsize(width = 600, height = 600)
    win2.maxsize(width = 600, height = 600)

    button2 = Button(win2, text = "Считать текст", command = getParameters, width = 20, height = 3, font = "Arial 8", bg = "#edf3fc", foreground = "#000000", activebackground = "#ffffff", relief = RAISED)
    button2.place(relx = 0.35, rely = 0.56)
    button2.bind()

    mainloop()
python
  • 1 个回答
  • 10 Views
Martin Hope
Каролина
Asked: 2020-04-01 14:16:47 +0000 UTC

比较 Python 中的列表和字典

  • 0

有一个列表和一个字典,您需要将列表的值与字典进行比较,如果值匹配,则从字典中调用函数。你需要让它成为一个循环。告诉我怎么做?

def max():
    x = 5
    return x

def min():
    y = 10
    return y

ex{
  "xx": sum(),
  "yy": min(),
  }

a = ["xx", "yy"]
python
  • 1 个回答
  • 10 Views
Martin Hope
Каролина
Asked: 2020-09-27 21:34:02 +0000 UTC

将数据从js传递到php

  • 0

我正在写一个投资计算器。总和大小由滑块设置并显示在 c id="summa2" 字段中。有必要通过按下“计算”按钮,将值从 summa2 字段读取到名为 $summa 的 php 变量中,使用 js 编写的 fun1 函数替换其中的值。未在 php 中读取该变量。

<!DOCTYPE html>
<html lang="rus">
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" type="text/css" href="style.css">
    <title>BANK</title>

    <script type="text/javascript" src="script.js" defer>
    </script>
</head>
<body>
    <div id="wrapper">
            <table id="calc">
                <form name="calc" method="post" action="calc.php">
                    <tr>
                        <td>Сумма вклада</td>
                        <td><input id="summa2" name="summa2" "type="number" min="1000" max="3000000" step="1" required value=""></td>
                        <td><input id="begunok" type="range" min="1000" max="3000000" step="1" value="" oninput="fun1()">
                        </td>
                    </tr>
                    <tr>
                        <td colspan="3"><input id="knopka" type="button" value="Рассчитать">Результат:</td>
                    </tr>   
                </form>
            </table>
        </div>

    </div>
</body>
</html> 
                            function fun1() {
                                 var rng2=document.getElementById('begunok'); 
                                      var summa2=document.getElementById('summa2'); 
                                      summa2.value=rng2.value;
                                      }
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST') {
   $summa = $_POST['summa2']; 
   echo $summa;
}
?>
javascript
  • 1 个回答
  • 10 Views
Martin Hope
Каролина
Asked: 2020-09-09 03:50:30 +0000 UTC

python解析器没有提取所有数据

  • 1

我正在尝试编写一个解析器来从网站中提取电影标题。其结果是,而不是 135 片的电影清单。只有一个出来。你能告诉我有什么问题吗?

import requests
from bs4 import BeautifulSoup
import csv

def get_html(url):
    r = requests.get(url)    # Получим метод Response
    r.encoding = 'utf8'
    return r.text   # Вернем данные объекта text

def csv_read(data2):
    with open("data2.csv", 'a') as file:
        writer = csv.writer(file)
        writer.writerow(data2['head'])

def get_link(html):
    soup = BeautifulSoup(html, 'lxml')
    head = soup.find('span', class_='name').find_all('a')
    heads = []
    for i in head:
        heads.append(i.string)
        data2 = {'head': heads}
        print(i.string)
    csv_read(data2)


data = get_link(get_html('https://www.kinopoisk.ru/name/31969/'))

我试图从中取名字的一段代码:

  <span class="num">16</span>
                        <table>
                            <tr>
                                <td>
                                    <span class="name">
                                        <a href="/film/695609/" >
                                            Джуманджи: Зов джунглей&nbsp;(2017)</a>, <font style='color: #393; white-space: nowrap'>$ 20&nbsp;000&nbsp;000 </font></span>
                                    <span class="role">
                                        Jumanji: Welcome to the Jungle&nbsp;...&nbsp;Spencer<span style="font-weight:bold;">
                                                    </span>
                                            <!--&nbsp;-->
                                    </span>
                                </td>
                            </tr>
                        </table>
                    </div>
                                        <div class="item" data-fid="1100776" data-imdbr="6.20" data-imdbv="570">

                                                <div class="rating kp">
                                                            <a href="/film/1100776/votes/">
                                    5.99
                                </a>
                                <span>139</span>
                                                    </div>
                        <div class="vote_widget miniVoteDiv rating_user_1100776">&nbsp;</div>

                        <div class="MyKP_Folder_Select  folder_film_1100776">
                            <s class="dot"></s>
                            <div class="arrow"></div>
                        </div>

                                                <span class="num">17</span>
                        <table>
                            <tr>
                                <td>
                                    <span class="name">
                                        <a href="/film/1100776/" >
                                            Линия жизни&nbsp;(сериал,&nbsp;2017)</a></span>
                                    <span class="role">
                                        Lifeline&nbsp;...&nbsp;Lifeline Customer<span style="font-weight:bold;">
                                                    </span>
                                            <!--&nbsp;-->
                                    </span>
                                </td>
                            </tr>
                        </table>
                    </div>
                                        <div class="item" data-fid="468940" data-imdbr="5.50" data-imdbv="142449">

                                                <div class="rating kp">
                                                            <a href="/film/468940/votes/">
                                    5.74
                                </a>
                                <span>38209</span>
                                                    </div>
                        <div class="vote_widget miniVoteDiv rating_user_468940">&nbsp;</div>

                        <div class="MyKP_Folder_Select  folder_film_468940">
                            <s class="dot"></s>
                            <div class="arrow"></div>
                        </div>

那些。您需要一个名称,例如“生命线”

<span class="name"> 
<a href="/film/1100776/" >Линия жизни&nbsp;(сериал,&nbsp;2017)</a></span>
python
  • 1 个回答
  • 10 Views
Martin Hope
Каролина
Asked: 2020-09-08 04:05:54 +0000 UTC

python替换方法

  • 3

程序将文本中的酒店一词更改为酒店。但是当酒店一词出现在另一个词中时会发生错误,例如,K -hotel -niki,即 程序改变了这个词中的短语。结果是 - Kgostinitsaniki。

怎么修?

简化的代码如下所示:

param = "Отель расположен в городе Котельники."
param = param.replace('отель','гостиница')
python
  • 2 个回答
  • 10 Views
Martin Hope
Каролина
Asked: 2020-02-12 16:33:55 +0000 UTC

Python 3.x 中的正则表达式错误

  • 1

我需要从文本中分离出所有句子(第一句除外),其中有一个关于公里的短语。

Магазин Автозапчастей находится в городе Москва. До него ехать 12 км. В магазине продаются автозапчасти от автомобиля Нива. Курган находится в 1000 км от магазина. 

我从点到点挑出句子。但是面具不起作用。请告诉我有什么问题。

import re

print('введите текст:')
x1 = str(input())
pattern = re.findall('\.\s\w+\s+(\d км*).*?\.', x1)
print(pattern)
python
  • 1 个回答
  • 10 Views
Martin Hope
Каролина
Asked: 2020-12-16 20:31:32 +0000 UTC

在Python中删除一个有距离的句子

  • 1

我试图确保只有文本中的最后一个句子,如果它包含关于里程的短语,则从文本中删除。但是面具不起作用。Python 3.7.1 程序 工作示例:一辆汽车在克拉斯诺亚尔斯克市出售。该物体位于 5 公里处。你需要开车15.2公里到市区。有必要只删除最后一句。对于掩码,检查是从最后开始的。将最后一句从一个点和一个空格中截断(倒数第二个句子以点和一个空格结尾)+ 最后一句中存在一个数字,短语 km 和最后一个点。需要有关如何修复它的建议。

import re
for a in range (0,100):
val = str(input("Введите текст: "))
res3=re.sub("(\.\s.\d.\км.\.*$", "", val)
print (res3)
python-3.x
  • 1 个回答
  • 10 Views
Martin Hope
Каролина
Asked: 2020-12-16 00:03:31 +0000 UTC

删除句子中两个单词之间的部分文本

  • 1

我有一个文本,每次都不一样。它经常多次得到这样的一句话:

到爱乐乐团的距离是 5 公里。

我需要删除python中从单词距离到点字符的一段文本。我无法确切知道到点符号的距离一词之后会是什么词。Python 有一个 re.findall 函数,我不知道如何为其中出现的所有此类商品创建搜索模式。Python 版本 3.7.1。

import re
val = str(input("Введите текст: "))
result = re.search('(Расстояние) +(\.)', val)
if result:
   print (result.group(0))
python
  • 1 个回答
  • 10 Views
Martin Hope
Каролина
Asked: 2020-11-26 08:06:50 +0000 UTC

SharedPreferences 中的设置不显示该数字

  • 0

我正在编写一个 Android 实验室。您需要创建一个存储帐户设置的程序。应该使用 Preferences 类在 onPause 和 onResume 函数中保存和恢复首选项。

我做了3个字段。2 个字段(名称和密码)是写为字符串的设置,第三个名为 identf 的设置是一个数字。通常使用 saveName 函数保存所有设置,但是当使用 getname 函数在屏幕上显示相同的设置时,应用程序退出。错误在数字的输出中。编译器在这两行上抛出错误。请帮我理解是什么原因。

Integer identf = settings.getInt(PREF_IDENTF, 0);
        identfView.setText(identf); 

下面是完整的代码。

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.a1.lab_3_1.MainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <EditText
            android:id="@+id/nameBox"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Введите логин"/>
        <EditText
            android:id="@+id/passwordBox"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Введите пароль"/>
        <EditText
            android:id="@+id/identfBox"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Введите идентификатор"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Сохранить"
            android:onClick="saveName"/>

        <TextView
            android:id="@+id/nameView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:id="@+id/passwordView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:id="@+id/identfView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Получить имя"
            android:onClick="getName"/>
    </LinearLayout>
</android.support.constraint.ConstraintLayout>

package com.example.a1.lab_3_1;

import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    private static final String PREFS_FILE = "account";
    private static final String PREF_NAME = "name";
    private static final String PREF_PAROL = "parol";
    private static final String PREF_IDENTF = "identf";
    SharedPreferences settings;
    SharedPreferences.Editor prefEditor;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        settings = getSharedPreferences(PREFS_FILE, MODE_PRIVATE);
    }


    public void saveName(View view) {
        // получаем введенное имя
        EditText nameBox = (EditText) findViewById(R.id.nameBox);
        String name = nameBox.getText().toString();

        EditText passwordBox = (EditText) findViewById(R.id.passwordBox);
        String parol = passwordBox.getText().toString();

        EditText identfBox = (EditText) findViewById(R.id.identfBox);
        Integer identf = Integer.parseInt (identfBox.getText().toString());
        // сохраняем его в настройках
        SharedPreferences.Editor prefEditor = settings.edit();
        prefEditor.putString(PREF_NAME, name);
        prefEditor.putString(PREF_PAROL, parol);
        prefEditor.putInt(PREF_IDENTF, identf);
        prefEditor.apply();
    }

    public void getName(View view) {
        // получаем сохраненное имя
        TextView nameView = (TextView) findViewById(R.id.nameView);
        String name = settings.getString(PREF_NAME,"не определено");
        nameView.setText(name);

        TextView passwordView = (TextView) findViewById(R.id.passwordView);
        String parol = settings.getString(PREF_PAROL,"не определено");
        passwordView.setText(parol);

        TextView identfView = (TextView) findViewById(R.id.identfView);
        Integer identf = settings.getInt(PREF_IDENTF, 0);
        identfView.setText(identf);
    }

    @Override
    protected void onPause(){
        super.onPause();

        EditText nameBox = (EditText) findViewById(R.id.nameBox);
        String name = nameBox.getText().toString();

        EditText passwordBox = (EditText) findViewById(R.id.passwordBox);
        String parol = passwordBox.getText().toString();

        EditText identfBox = (EditText) findViewById(R.id.identfBox);
        Integer identf = Integer.parseInt (identfBox.getText().toString());
        // сохраняем в настройках
        prefEditor = settings.edit();
        prefEditor.putString(PREF_NAME, nameBox.getText().toString());
        prefEditor.putString(PREF_PAROL, passwordBox.getText().toString());
        prefEditor.putInt(PREF_IDENTF, identf);
        prefEditor.apply();
    }


}
java
  • 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