戈亓

文章 评论 浏览 28

戈亓 2025-02-05 00:01:03

tl; dr答案:

您可以将其视为另一个封装级别 - 在受保护 private 之间:您不能从儿童班上称呼它,但是您可以覆盖它。

实现模板方法设计模式时,这很有用。您可以使用受保护的,但是私人 Virtual 一起可以被认为是更好的选择,因为封装更好。

TL;DR answer:

You can treat it like another level of encapsulation - somewhere between protected and private: you can't call it from child class, but you can override it.

It is useful when implementing Template Method design pattern. You could use protected, but private together with virtual may be considered as better choice, because of better encapsulation.

私人纯虚拟功能的重点是什么?

戈亓 2025-02-04 22:28:44

这是因为 \ d+模式仅允许数字序列。如果您想要类似sl的序列,则可以使用:

from django.conf.urls import url
from django.contrib import admin
from olvapp import views

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^register/(?P<pk>[-\w]+)',views.guaform,name='custform'),
]

注意 django-1.11 自2020年4月以来,您应该考虑升级Django版本。


That's because of the \d+ pattern which only allows a sequence of digits. If you want a slug-like sequence, you can use:

from django.conf.urls import url
from django.contrib import admin
from olvapp import views

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^register/(?P<pk>[-\w]+)',views.guaform,name='custform'),
]

Note: is no longer supported [Django-doc] since April 2020, you should consider upgrading the Django version.

我该如何在Django 1.11中进行URL弹性?

戈亓 2025-02-04 05:52:32

如果要使用 async ,则需要将事件处理程序更改为 async ,因此您可以使用等待,请参阅以下内容:

1。将事件处理程序更改为 async void async void 在事件处理程序方法上是可以接受的,您应该尝试使用 async Task 代替 async void 在大多数其他情况下,因此将方法签名更改为以下内容:

   private async void btnOK_Click(object sender, EventArgs e)
   {
        if (txtItemURL.Text.StartsWith("https://steamcommunity.com/market/listings/730/") == true)
        {
            Helpers.Helper.BuildURL(txtItemURL.Text);
            //here we use await to await the task   
            SteamMarketItem SMI = await Helpers.Helper.GetItemDetails();
            lblPrice.Text = SMI.LowestPrice.ToString() + "$";
            pbItemImage.ImageLocation = SMI.ImagePath;

            Helpers.Helper.Kontrollar_BerpaEt();
        }
        else
        {
            Helpers.Helper.Kontrollar_SifirlaYanlisDaxilEdilib();
        }
   }

2。您不需要使用 task.run < /code>, httpclient 公开 async 方法,您可以使方法 async ,也可以调用。result ysync 方法的块通常不是一个好主意,您应该制作封闭方法 async ,因此您可以使用等待

   //Change signature to async and return a Task<T>
   public async static Task<SteamMarketItem> GetItemDetails()
   {
       WinForms.Control.CheckForIllegalCrossThreadCalls = false;
       //what is marketItem?? Where is it declared?
       try
       {
           using (HttpClient client = new HttpClient())
           {
               JavaScriptSerializer serializer = new JavaScriptSerializer();

                /* Get item info: */
                var ResultFromEndpoint1 = await client.GetAsync(ReadyEndpointURL1);
                var Json1 = await ResultFromEndpoint1.Content.ReadAsStringAsync();
                dynamic item = serializer.Deserialize<object>(Json1);
                marketItem.LowestPrice = float.Parse(((string)item["lowest_price"]).Replace("$", "").Replace(".", ","));

                /* Get item image: */
                var ResultFromEndpoint2 = await client.GetAsync(ReadyEndPointURL2);
                var Json2 = await ResultFromEndpoint2.Content.ReadAsStringAsync();
                var html = ((dynamic)serializer.Deserialize<object>(Json2))["results_html"];

                HtmlDocument htmlDoc = new HtmlDocument();
                htmlDoc.LoadHtml(html);
                marketItem.ImagePath = htmlDoc.DocumentNode.SelectSingleNode("//img[@class='market_listing_item_img']").Attributes["src"].Value + ".png";

                Kontrollar_BerpaEt();
           }
       }
       catch
       {
            Kontrollar_SifirlaYanlisDaxilEdilib();
       }
       //what is marketItem?? Where is it declared?
       return marketItem;
   }

If you want to use async you need to change your event handler to async so you can use await, please see the following:

1. Change your Event handler to async void, async void is acceptable on event handler methods, you should try to use async Task in place of async void in most other cases, so change your method signature to the following:

   private async void btnOK_Click(object sender, EventArgs e)
   {
        if (txtItemURL.Text.StartsWith("https://steamcommunity.com/market/listings/730/") == true)
        {
            Helpers.Helper.BuildURL(txtItemURL.Text);
            //here we use await to await the task   
            SteamMarketItem SMI = await Helpers.Helper.GetItemDetails();
            lblPrice.Text = SMI.LowestPrice.ToString() + "
quot;;
            pbItemImage.ImageLocation = SMI.ImagePath;

            Helpers.Helper.Kontrollar_BerpaEt();
        }
        else
        {
            Helpers.Helper.Kontrollar_SifirlaYanlisDaxilEdilib();
        }
   }

2. You shouldn't need to use Task.Run, HttpClient exposes async methods and you can make the method async, also, calling .Result to block on an async method is typically not a good idea and you should make the enclosing method async so you can utilize await:

   //Change signature to async and return a Task<T>
   public async static Task<SteamMarketItem> GetItemDetails()
   {
       WinForms.Control.CheckForIllegalCrossThreadCalls = false;
       //what is marketItem?? Where is it declared?
       try
       {
           using (HttpClient client = new HttpClient())
           {
               JavaScriptSerializer serializer = new JavaScriptSerializer();

                /* Get item info: */
                var ResultFromEndpoint1 = await client.GetAsync(ReadyEndpointURL1);
                var Json1 = await ResultFromEndpoint1.Content.ReadAsStringAsync();
                dynamic item = serializer.Deserialize<object>(Json1);
                marketItem.LowestPrice = float.Parse(((string)item["lowest_price"]).Replace("
quot;, "").Replace(".", ","));

                /* Get item image: */
                var ResultFromEndpoint2 = await client.GetAsync(ReadyEndPointURL2);
                var Json2 = await ResultFromEndpoint2.Content.ReadAsStringAsync();
                var html = ((dynamic)serializer.Deserialize<object>(Json2))["results_html"];

                HtmlDocument htmlDoc = new HtmlDocument();
                htmlDoc.LoadHtml(html);
                marketItem.ImagePath = htmlDoc.DocumentNode.SelectSingleNode("//img[@class='market_listing_item_img']").Attributes["src"].Value + ".png";

                Kontrollar_BerpaEt();
           }
       }
       catch
       {
            Kontrollar_SifirlaYanlisDaxilEdilib();
       }
       //what is marketItem?? Where is it declared?
       return marketItem;
   }

为什么第一次单击按钮不起作用的事件

戈亓 2025-02-03 14:44:47

您可以使用MAP TILE API在背景中显示映射,如此示例所示: https://demo.support.here.com/examples/v3.1/simple_routing

(function(){
/*
作者
(c)在这里2019年
*/

var mapContainer = document.getElementById('mapContainer');

// check if the site was loaded via secure connection
var secure = (location.protocol === 'https:') ? true : false;

var platform = new H.service.Platform({
        useHTTPS: secure,
        apikey: api_key
    }),
    defaultLayers = platform.createDefaultLayers(),
    router = platform.getRoutingService(),

    map = new H.Map(mapContainer, defaultLayers.vector.normal.map,
        {
            center: center,
            zoom: zoom,
            pixelRatio: window.devicePixelRatio || 1
        }
    );

// Do not draw under control panel
map.getViewPort().setPadding(0, 0, 0, $('.ctrl-panel').width());

// add behavior control
new H.mapevents.Behavior(new H.mapevents.MapEvents(map));

// Enable the default UI
var ui = H.ui.UI.createDefault(map, defaultLayers);

window.addEventListener('resize', function() { map.getViewPort().resize(); });

function calculateRoute()
{
    var calculateRouteParams = {

        'waypoint0' : '52.516222,13.388900',
        'waypoint1' : '52.517175,13.395129',
        'mode': 'fastest;car;traffic:disabled',
        'representation': 'display'
    },
    onResult = function(result) {
        var lineString = new H.geo.LineString(),
            routeShape = result.response.route[0].shape,
            polyline;

        routeShape.forEach(function(point) {
            var parts = point.split(',');
            lineString.pushLatLngAlt(parts[0], parts[1]);
        });

        var polyline = new H.map.Polyline(lineString,
            {
                style:
                {
                    lineWidth: 10,
                    strokeColor: "rgba(0, 128, 0, 0.7)"
                }
            });

        map.addObject(polyline);
        map.getViewModel().setLookAtData({
            tilt: 45,
            bounds: polyline.getBoundingBox()
        });
    },
    onError = function(error) {
        console.log(error);
    }
    router.calculateRoute(calculateRouteParams, onResult, onError);
}

var displayReady = function(e)
{
    map.removeEventListener("mapviewchangeend", displayReady);
    calculateRoute();
};

map.addEventListener("mapviewchangeend", displayReady);

})

you can use map tile api to to show map in the background as shown in this sample example : https://demo.support.here.com/examples/v3.1/simple_routing

(function(){
/*
author
(C) HERE 2019
*/

var mapContainer = document.getElementById('mapContainer');

// check if the site was loaded via secure connection
var secure = (location.protocol === 'https:') ? true : false;

var platform = new H.service.Platform({
        useHTTPS: secure,
        apikey: api_key
    }),
    defaultLayers = platform.createDefaultLayers(),
    router = platform.getRoutingService(),

    map = new H.Map(mapContainer, defaultLayers.vector.normal.map,
        {
            center: center,
            zoom: zoom,
            pixelRatio: window.devicePixelRatio || 1
        }
    );

// Do not draw under control panel
map.getViewPort().setPadding(0, 0, 0, $('.ctrl-panel').width());

// add behavior control
new H.mapevents.Behavior(new H.mapevents.MapEvents(map));

// Enable the default UI
var ui = H.ui.UI.createDefault(map, defaultLayers);

window.addEventListener('resize', function() { map.getViewPort().resize(); });

function calculateRoute()
{
    var calculateRouteParams = {

        'waypoint0' : '52.516222,13.388900',
        'waypoint1' : '52.517175,13.395129',
        'mode': 'fastest;car;traffic:disabled',
        'representation': 'display'
    },
    onResult = function(result) {
        var lineString = new H.geo.LineString(),
            routeShape = result.response.route[0].shape,
            polyline;

        routeShape.forEach(function(point) {
            var parts = point.split(',');
            lineString.pushLatLngAlt(parts[0], parts[1]);
        });

        var polyline = new H.map.Polyline(lineString,
            {
                style:
                {
                    lineWidth: 10,
                    strokeColor: "rgba(0, 128, 0, 0.7)"
                }
            });

        map.addObject(polyline);
        map.getViewModel().setLookAtData({
            tilt: 45,
            bounds: polyline.getBoundingBox()
        });
    },
    onError = function(error) {
        console.log(error);
    }
    router.calculateRoute(calculateRouteParams, onResult, onError);
}

var displayReady = function(e)
{
    map.removeEventListener("mapviewchangeend", displayReady);
    calculateRoute();
};

map.addEventListener("mapviewchangeend", displayReady);

})

我如何沿着路线获得所有行政部门/边界?

戈亓 2025-02-03 14:10:59

您可以使用contains()方法进行字符串

You can use contains() method for string

Django-如何使用过滤器检查字符串字段是否包含一个单词?

戈亓 2025-02-03 02:03:28

似乎您需要在CSS中添加最大宽度:100% #pemap 。否则它总是宽度为850px。

Seems like you need to add max-width: 100% in the css to #peMap. Otherwise it’s always 850px wide.

如何使传单响应?

戈亓 2025-02-02 13:14:49

您可以使用JSON解码器在字符串切片中解码值

var arr []string
err := json.NewDecoder(req.Body).Decode(&arr)
if err != nil {
    fmt.Fprintf(w,fmt.Sprintf("Error:%+v",err))
    return
}
fmt.Println(arr)

You can use json decoder to decode the values in slice of string

var arr []string
err := json.NewDecoder(req.Body).Decode(&arr)
if err != nil {
    fmt.Fprintf(w,fmt.Sprintf("Error:%+v",err))
    return
}
fmt.Println(arr)

使用卷发将数组发送到Golang Server

戈亓 2025-02-02 09:56:31

您无法在不包含在FormGroup中的情况下使用FormGroupName(请参阅控制台中的错误)。

声明一个变量

subSubForm:FormGroup

因此,在ngoninit使用

  ngOnInit() {
    ...
    this.subSubForm=this.fgd.form.get('childForm') as FormGroup
    ...
  }

和.html中

<!--see that use [FormGroup] -->
<div [formGroup]="subSubForm">
  <p>Child</p>
  <input type="text" formControlName="childInput" />
</div>

You can not use formGroupName without enclosed in a formGroup (see the errors in console).

So, declare a variable

subSubForm:FormGroup

Then, in ngOnInit use

  ngOnInit() {
    ...
    this.subSubForm=this.fgd.form.get('childForm') as FormGroup
    ...
  }

And in .html

<!--see that use [FormGroup] -->
<div [formGroup]="subSubForm">
  <p>Child</p>
  <input type="text" formControlName="childInput" />
</div>

如何使用FormGroupDiractive将控件添加到子组件中的子形式?

戈亓 2025-02-01 20:54:56

也许是因为图像的大小

Maybe it's because the size of the image

如何在Appbar中使用图标图像

戈亓 2025-02-01 06:58:00

您可以做一些简单的事情:

match(u:User{id:'regular'})-[*0..]->()-[:can_edit]->(r:Resource)  

这将确保资源为[:can_edit]之前的最后一个关系

You can do something simple like:

match(u:User{id:'regular'})-[*0..]->()-[:can_edit]->(r:Resource)  

This will make sure the the last relationship before the Resource is [:can_edit]

Cypher匹配连接到通过最后关系过滤的节点的任何节点

戈亓 2025-02-01 06:55:26

回答

答案---&gt;我忘了创建一个适配器类的实例

解决方案-----&gt;

adapterRecVHomeFrag adapter;

添加此行以创建适配器类类型的变量。

Answer

Answer ---> I forgot to create an instance of adapter class

Solution ----->

adapterRecVHomeFrag adapter;

add this line to create a variable of adapter class type.

如何使用filter.getFilter()。滤波器(newText)方法在片段中android

戈亓 2025-01-31 14:33:33

您是否确定使用JSON Body-Parser作为中间软件,如果没有,则不会在 req.body 上使用 body

您可以通过NPM安装身体偏好器:
NPM安装Body-Parser

,然后使用中间软件,如下所示:


    const bodyParser = require("body-parser");
    app.use(bodyParser.json())

有关更多信息,请查看官方Express Docs 在这里

Are you sure you are using json body-parser as a middle-ware, if not, there won't be a body on req.body.

you can install body-parser via npm:
npm install body-parser

and then use the middle-ware as shown below:


    const bodyParser = require("body-parser");
    app.use(bodyParser.json())

for more information check the official express docs here.

如何在请求nodejs中返回身体

戈亓 2025-01-31 00:24:02

我检查了您的代码。有一些小错误。检查我的示例并评论您是否有解决问题的解决方案,谢谢。

Public Class Form1
Private Sub TxtRemise_TextChanged(sender As Object, e As EventArgs) Handles TxtRemise.TextChanged
    Dim TotalTTc As Decimal
    TotalTTc = CDec(TotalHT.Text) + CDec(TXTMontantTva.Text)
    TxtTTC.Clear()
    TxtTTC.Text = (TotalTTc - CDec(TxtRemise.Text)).ToString
End Sub
End Class

I checked your code. There was some little mistakes. Check my example and comment if you had the solution to your question, thank you.

Public Class Form1
Private Sub TxtRemise_TextChanged(sender As Object, e As EventArgs) Handles TxtRemise.TextChanged
    Dim TotalTTc As Decimal
    TotalTTc = CDec(TotalHT.Text) + CDec(TXTMontantTva.Text)
    TxtTTC.Clear()
    TxtTTC.Text = (TotalTTc - CDec(TxtRemise.Text)).ToString
End Sub
End Class

从double到字符串vb.net的隐式转换

戈亓 2025-01-31 00:09:44

仅用于寄存器:

如果您在不是“管理员”(计算机的主要用户)的用户中安装,则可能会发生这种情况。

为了澄清,它是“管理员”用户,而不是管理员组中的用户。

与管理员一起运行,我在有问题的计算机上取得了成功。

Only for register:

if you run install in a user that is not the "Administrator", main user of the computer, this can happen.

To clarify, it is the "Administrator" user and not a user in the Administrators group.

Running with Administrator I had success on the computers that had problems.

delphi 11.1安装冻结安装“核心通用文件企业功能&quot”,为什么?

戈亓 2025-01-30 23:16:59

请参阅此问题< /a>

img_plot = img.numpy().transpose(1, 2, 0)
plt.imshow(img_plot)

Please refer to this question

img_plot = img.numpy().transpose(1, 2, 0)
plt.imshow(img_plot)

pytorch张量以更改维度

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文