小编mil*_*uts的帖子

Python httplib.InvalidURL:非数字端口失败

我正在尝试在Python中打开需要用户名和密码的URL.我的具体实现如下:

http://char_user:char_pwd@casfcddb.example.com/......
Run Code Online (Sandbox Code Playgroud)

我得到以下错误吐到控制台:

httplib.InvalidURL: nonnumeric port: 'char_pwd@casfcddb.example.com'
Run Code Online (Sandbox Code Playgroud)

我正在使用urllib2.urlopen,但错误暗示它不理解用户凭据.它看到":"并期望端口号而不是密码和实际地址.我在这里做错了什么想法?

python urllib2 python-2.7

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

没有指定大小的C#数组

当我不知道元素的确切数量时,我有一个关于在C#中创建数组的问题.我发现了很多类似的问题,比如这个问题.建议使用List而不是Array.在那个例子和其他所有例子中,我看到它实例化了一个'字符串列表'.我可以用结构做同样的事情吗?

例如,我有以下用于存储故障信息的结构,但我不知道在测试开始时会发生多少次故障.它可能是0,可能是数百.

    public struct EraseFailures
    {
        public string timestamp;
        public string bus;
        public string channel;
        public string die;
        public string block;
    }
Run Code Online (Sandbox Code Playgroud)

那么我也可以创建这些列表吗?

    List<EraseFailures> eFails = new List<EraseFailures>();
Run Code Online (Sandbox Code Playgroud)

它编译得很好,但我想确保这是最好的方法.如果是,将值添加到我的列表的语法是什么?因为以下似乎不正确......

     eFails.bus.Add("bus0");
Run Code Online (Sandbox Code Playgroud)

好像我可能要创建一个包含我想要的值的新结构,然后将其添加到List中.

c# arrays struct list

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

Windows 和 Linux 之间的 git status 不一致

如果我在 Linux 系统和 Windows10 笔记本电脑上运行 Git status,它会返回不同的结果。

原始目录是在 Linux 机器(运行 RedHat 6.4)上启动的。我厌倦了使用 VIM 编辑所有 Python 代码,因此决定将 Windows10 笔记本电脑上的网络驱动器映射到远程 Linux 盒子(控制我们所有的测试设备)和使用 Git 设置的目录。现在我可以使用 Visual Studio Code 轻松查看/编辑/更新远程 Linux 计算机上的任何文件。我从 Linux 机器上运行所有 git 命令,但如果我可以直接从 VS Code 运行它们那就太好了,但这两个版本的 Git 之间显然存在差异。

'git status' --> on the Linux box returns no updated or modified files.

'git status' --> on Windows shows I have over 200 modified files and 2 directories that are deleted.
Run Code Online (Sandbox Code Playgroud)

我已经浏览过这个线程: Git - Windows AND linux line-endings

我尝试过那里有很多很棒的信息。唯一似乎有任何效果的事情是添加“git config core.filemode false” …

linux windows git visual-studio

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

文件上传中缺少文件类型

我有一个页面,允许我上传CSV文件.使用PHP我然后获取CSV文件的内容并将它们插入MySQL数据库.我现在一直没有遇到任何问题.然后今天,我尝试上传文件,但它没有用.问题是似乎没有与CSV文件关联的文件类型.例如,在良好的上传中,我吐出的调试消息如下所示:

You uploaded a file: buylist_235.csv 
file type: application/vnd.ms-excel 
file size: 10456 

File is valid, and was successfully uploaded. Here is some more debugging info:Array (
        [csv] => Array
            (
                [name] => buylist_235.csv
                [type] => application/vnd.ms-excel
                [tmp_name] => C:\xampp\tmp\php3C1E.tmp
                [error] => 0
                [size] => 10456
            )
)
Run Code Online (Sandbox Code Playgroud)

但是,当我上传带有调试消息的问题文件时,我注意到文件类型和文件大小为空.

You uploaded a file: buylist_235_1.csv
file type: 
file size: 0

Possible file upload attack!
Here is some more debugging info:Array
(
    [csv] => Array
        (
            [name] => buylist_235_1.csv
            [type] => 
            [tmp_name] => …
Run Code Online (Sandbox Code Playgroud)

html php csv

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

C#For循环没有正确迭代

我有一个4字节的值,我转换为Int32,然后在文本框中显示它.没有问题.当我尝试用0填充字符串时出现问题.当我显示十进制数时,它应该总是包含8个字符,所以如果它小于我想要用0填充它.

string parmDecString = BitConverter.ToInt32(testNum, 0).ToString();
Console.WriteLine("length: {0} - {1}", parmDecString.Length, (8 - parmDecString.Length));
for (int l=0; l < (8-parmDecString.Length); l++)
{
    parmDecString = "0" + parmDecString;
}
textBox74.Text = parmDecString;
Run Code Online (Sandbox Code Playgroud)

这是我根据不同的'parmDecString'值得到的文本框中的输出:

parmDecString = "123"
Console:  length: 3 - 5
textbox:  000123   <=== only 3 times in the 'for' loop, expected 5x

parmDecString = "12345"
Console:  length: 5 - 3
textbox:  0012345   <=== only 2 times in the 'for' loop, expected 3x

parmDecString = "12345678"
Console:  length: 8 - 0 …
Run Code Online (Sandbox Code Playgroud)

c# for-loop

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

标签 统计

c# ×2

arrays ×1

csv ×1

for-loop ×1

git ×1

html ×1

linux ×1

list ×1

php ×1

python ×1

python-2.7 ×1

struct ×1

urllib2 ×1

visual-studio ×1

windows ×1