小编gun*_*ert的帖子

%E2%80%8B 出现在 url .Net Core

我从未遇到过这样的问题,但它显示为路线的一部分,如果我手动输入路线,则结果为404.

如果我从招摇%E2%80%8B出现复制。

我该如何解决这个问题?

.Net 核心 2.1

http://localhost/functionCodes/%E2%80%8Btest - 有效

http://localhost/functionCodes/test - 404

.net url whitespace asp.net-core

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

运行时错误.整数转换为字符串

我目前正在创建一个程序,它返回数字的序数形式(第1个,第2个等).但是当我运行我的程序时,我得到一个运行时错误.

我怀疑它与我从int转换为字符串有关,但我似乎无法找到问题的根源.

public void run() {
        ordinalform(5);
    }

    private String ordinalform(int num) {
        String number = Integer.toString(num);
        String correctWord ="";
        if((number.charAt(number.length()-2)=='1'
                && number.charAt(number.length()-1)=='1')){
            correctWord=number+"th";
        } else if (number.charAt(number.length()-2)=='1'
                && number.charAt(number.length()-1)=='2') {
            correctWord=number+"th";
        } else if ((number.charAt(number.length()-1)=='1'
                && number.charAt(number.length()-1)=='3')) {
            correctWord=number+"th";
        } else if(number.charAt(number.length()-1)=='1') {
            correctWord=number+"st";
        } else if(number.charAt(number.length()-1)=='2') {
            correctWord=number+"nd";
        } else if(number.charAt(number.length()-1)=='3') {
            correctWord=number+"rd";
        } else {
            correctWord=number+"th";
        }
        println(correctWord);
        return correctWord;
    }
}
Run Code Online (Sandbox Code Playgroud)

错误: Exception in thread "Thread-1" java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.charAt(String.java:646) at …

java string int type-conversion

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

C#Typecast一个结构的枚举

我正在使用C#,我必须操纵屏幕上的对象.我设置了一个结构来保存坐标,然后我设置一个枚举来限制可以移动的方向的数量.

private enum Direction
{
    UpperLeft = new Coord(-1, -1), 
    UpperCenter = new Coord(0, -1), 
    UpperRight = new Coord(1, -1),
    Left = new Coord(-1, 0), 
    Right = new Coord(1, 0),
    LowerLeft = new Coord(-1, 1), 
    LowerCenter = new Coord(0, 1),
    LowerRight = new Coord(1, 1)
};

private struct Coord
{
    public int row { get; private set; }
    public int col { get; private set; }
    public Coord(int r, int c) : this()
    {
        row = r;
        col = c; …
Run Code Online (Sandbox Code Playgroud)

c# enums struct

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

Python:词典中的词典?

我在尝试执行一个非常简单的练习时需要帮助,只是在语法上我有点迷路。

基本上,我阅读了一个非常简短的文本文件,其中包含15行的3个元素(基本上是2个键和一个值)

  • 将这些元素放入由字典组成的字典中
  • 第一个字典包含位置,第二个字典包含项的类型及其费用

例如:

地点项目费用
------------------------
体育馆重量15 

市场谷物5

体育鞋50

轿车啤酒3

轿车威士忌10

市场面包5

这将导致

{'gymnasium':{'weights':15,15,'shoes':50}
等等其他键

基本上,我需要遍历此文件,但是我很难读取内容作为辞典。此外,没有那部分,我无法弄清楚如果外部列表中的键实例发生,如何将内部列表追加到外部列表。

python dictionary

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

从字符串列表中获取唯一值

我有一个像这样的字符串列表:

{"100", "101, "101", "102, "103, "103", "104", "104", "105"}

我需要获得一个只有不同值的新字符串列表:

{"100","101","102","103","104","105"}

有人有快速的方法吗?

c# list

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

如何将嵌套列表转换为字典?

我想采用嵌套列表,例如:

list = [[Name, Height, Weight],[Dan, 175, 75],[Mark, 165, 64], [Sam, 183, 83]]
Run Code Online (Sandbox Code Playgroud)

并将其转换为字典,如:

dict = {Name: [Dan,Mark, Sam], Height: [175, 165, 183], Weight: [75, 64, 83]}
Run Code Online (Sandbox Code Playgroud)

不幸的是,我当前的代码并没有真正给我我正在寻找的字典格式。

list = [[Name, Height, Weight],[Dan, 175, 75],[Mark, 165, 64], [Sam, 183, 83]]
Run Code Online (Sandbox Code Playgroud)

有人可以帮助我并找出我哪里出错了吗?

python dictionary nested-lists

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