小编tsh*_*ang的帖子

从Python列表中的项创建新的空列表?

my_list = ['c1','c2','c3']
Run Code Online (Sandbox Code Playgroud)

反正是否有基于列表中的项目创建一定数量的新列表?

结果将是:

c1 = []
c2 = []
c3 = []
Run Code Online (Sandbox Code Playgroud)

python function list

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

如何在C++中生成unix时间戳?

我将第二个,分钟,小时,日,月和年作为我的应用程序中的单个值,并且需要从此值生成一个unix时间戳.

我只找到了如何直接获得C函数的时间戳的解决方案.

如何使用C++中的给定值生成unix时间戳?

c++ time timestamp

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

如何解决"bash:ls:command not found"

我做了一些错误的PATH,所以目前如果我键入ls命令我得到:

bash: ls: command not found
Run Code Online (Sandbox Code Playgroud)

我该如何解决?

linux bash

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

无法在C中显示文件的内容

我试图读取一个名为的文件的内容,pp.txt并在命令行上显示它的内容.我的代码是:

#include<stdio.h>
#include<stdlib.h>
int main()
{

FILE *f;
float x;


f=fopen("pp.txt", "r");

if((f = fopen("pp.txt", "r")) == NULL)
{
fprintf(stderr, "Sorry! Can't read %s\n", "TEST1.txt");
}

else
{
printf("File opened successfully!\n");
}

fscanf(f, " %f", &x);

if (fscanf(f, " %f ", &x) != 1) {
fprintf(stderr, "File read failed\n");
return EXIT_FAILURE;
}

else
{
printf("The contents of file are: %f \n", x);
}


fclose(f);

return 0;
}
Run Code Online (Sandbox Code Playgroud)

编译后我得到了File opened successfully!File read failed.我的内容pp.txt是34.5.谁能告诉我哪里出错了?

c file-io file

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

试图用C运行程序

有人可以帮我运行这个程序吗?我试过这个:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void) {
    double Cateto1;
    double Cateto2;
    double hipotenusa;

    printf("dame el primer cateto: ");
    scanf("%1f", Cateto1);
    fflush(stdout);

    printf("dame el segundo cateto: ");
    scanf("%1f", &Cateto2);
    fflush(stdout);

    hipotenusa = sqrt ((Cateto1*Cateto1)+(Cateto2*Cateto2));

    printf("hipotenusa= %2f",hipotenusa);
    system("pause");
}
Run Code Online (Sandbox Code Playgroud)

我可以建立它,但我无法运行它...它给了我:

RUN FAILED(退出值-1.073.741.790,总时间:17s)

c

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

JavaScript在变量名中有一个变量

我有一个变量varName,其内容为"myvar".我想创建一个名称variable和内容的变量varName,因此名称将是variablemyVar.

我该怎么做呢?

html javascript variables

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

在 Python IO 错误中解析 XML

我知道这个问题已经在堆栈上被多次询问(和回答)。我已经尝试了很多,但由于某种原因我无法克服这个错误:

Traceback (most recent call last):
  File "J:\eclipse\workspace_python\TF2_Monitor\src\TF2_Monitor.py", line 23, in <module>
    xmldoc = minidom.parse(sampleXML)
  File "C:\Python27\lib\xml\dom\minidom.py", line 1920, in parse
    return expatbuilder.parse(file)
  File "C:\Python27\lib\xml\dom\expatbuilder.py", line 922, in parse
    fp = open(file, 'rb')
IOError: [Errno 2] No such file or directory: '<?xml version = "1.0" encoding = "utf-8"?>\n<Patients>\n    <Patient>\n               <PatientCharacteristics>\n                   <patientCode>3</patientCode>\n               </PatientCharacteristics>\n    </Patient>\n</Patients>'
Run Code Online (Sandbox Code Playgroud)

这是导致问题的代码位:-

if __name__ == '__main__':
   from xml.dom import minidom

   sampleXML = """<?xml version = "1.0" encoding = "utf-8"?>
   <Patients>
      <Patient>
           <PatientCharacteristics>
               <patientCode>3</patientCode>
           </PatientCharacteristics>
      </Patient>
   </Patients>"""


   xmldoc = …
Run Code Online (Sandbox Code Playgroud)

python xml

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

C#/ XML读取XML文件不起作用

我想读取XML文件并保存InnerText-Strings,但它会因SystemNullReference错误而崩溃.我认为我读它的方式是错误的,但我不确定.

XML的文件:

<?xml version="1.0" encoding="Windows-1252" standalone="no"?>
<schema>
  <Hintergrund>#FFFFFFFF</Hintergrund>
  <Zahlen>#FFFFFFFF</Zahlen>
  <Text>#FFFFFFFF</Text>
  <Zeichenketten>#FFFFFFFF</Zeichenketten>
  <Tags>#FF000000</Tags>
  <Direktiven>#FF000000</Direktiven>
  <Ausdruecke>#FF000000</Ausdruecke>
  <Initialisierer>#FF000000</Initialisierer>
  <Modifizierer>#FF000000</Modifizierer>
  <Booleanische>#FF000000</Booleanische>
  <Operator>#FF000000</Operator>
  <Kommentare>#FF000000</Kommentare>
</schema>
Run Code Online (Sandbox Code Playgroud)

读:

foreach (XmlNode node in doc.SelectNodes("/schema/*"))
{
    switch (node.Name)
    {
        case "Hintergrund":
            colorBG = (Color)ColorConverter.ConvertFromString(node["Hintergrund"].InnerText);
            break;
        case "Zahlen":
            colorNumbers = (Color)ColorConverter.ConvertFromString(node["Zahlen"].InnerText);
            break;
        case "Text":
            colorText = (Color)ColorConverter.ConvertFromString(node["Text"].InnerText);
            break;
        case "Zeichenketten":
            colorStrings = (Color)ColorConverter.ConvertFromString(node["Zeichenketten"].InnerText);
            break;
        case "Tags":
            colorTags = (Color)ColorConverter.ConvertFromString(node["Tags"].InnerText);
            break;
        case "Direktiven":
            colorDirectives = (Color)ColorConverter.ConvertFromString(node["Direktiven"].InnerText);
            break;
        case "Ausdruecke":
            colorStatements = (Color)ColorConverter.ConvertFromString(node["Ausdruecke"].InnerText);
            break;
        case "Initialisierer":
            colorInitial = (Color)ColorConverter.ConvertFromString(node["Initialisierer"].InnerText);
            break;
        case "Modifizierer": …
Run Code Online (Sandbox Code Playgroud)

.net c# xml wpf file-io

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

代码中的 C# 命令行

我试图在我的 C# 代码中使用此命令“winsatformal”运行隐藏控制台,但它在“Process.Start()”中给出错误。这是我的代码:

string command = "winsat formal";

Process process = new Process();
process.StartInfo.FileName = command;
process.Start();
Run Code Online (Sandbox Code Playgroud)

c# console command-line

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

请帮助我理解阅读偏好的一部分

所以我对java/android仍然有点新,我试图读取一个偏好值,但我试图理解它的每个部分,所以它对我来说更有意义......

SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
boolean soundEnabledPref = sharedPref.getBoolean("sound", soundEnabled);
Run Code Online (Sandbox Code Playgroud)

在getBoolean中,我试图理解第一个字符串是什么"声音",以及soundEnabled boolean的用途.

所以我已经声明soundEnabled作为布尔值顶部,我猜这是存储我正在检索的值的东西?

虽然"声音",第一个字符串的目的是什么?我想确保我正确地命名它,如果它用于存储某些东西,或者如果我用它引用某些东西,那么我可能需要将它命名为不同的东西.

我已经阅读了开发人员的文档,但仍然有点困惑,所以如果有人能给我一个快速的解释,我会非常感激!

java android boolean preferences

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

标签 统计

c ×2

c# ×2

file-io ×2

python ×2

xml ×2

.net ×1

android ×1

bash ×1

boolean ×1

c++ ×1

command-line ×1

console ×1

file ×1

function ×1

html ×1

java ×1

javascript ×1

linux ×1

list ×1

preferences ×1

time ×1

timestamp ×1

variables ×1

wpf ×1