小编Ale*_*ine的帖子

我不知道如何解决此错误,python3语法错误“ def”

我想解决这个错误。我尝试了近半小时,但找不到答案。

这是我的错误

 File "sampling_fun.py", line 71
    def average(self) :
      ^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)

和完整的代码

import csv

class fun :
    def __init__(self, rowList, num) :
        list = []
        listLen = len(self.rowlist)-1
        for i in range(listLen) :
            list.append(self.rowList[i+1][num]  # num = Header 1~4

    def average(self) :
        ave = sum(self.list)/self.lestLen
        print("average : %0.2f" %ave)
        return ave

testlist = cssRead('Data_2', 1)
test1 = fun(testlist, 1)
test1.average()
Run Code Online (Sandbox Code Playgroud)

python function syntax-error python-3.x

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

如何解密这个密码哈希?

我搜索了很多用于解密的信息,但没有人可以告诉我这是什么类型的加密以及如何解密0x010056049b0e92e4e85487c8a63385cdb89bdd66cb7f28cab34e

了解更多信息

密码哈希:0x010056049b0e92e4e85487c8a63385cdb89bdd66cb7f28cab34e标题:0x0100 salt:56049b0e mixedcase:92e4e85487c8a63385cdb89bdd66cb7f28cab34e

任何人都可以教我如何生存这个我对此全新

encryption passwords hash

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

只有css的最后一个链接起作用

我有三个不同大小的设备的这三个CSS链接.

<link href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/maxwidth959.css" rel='stylesheet'>
<link href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/maxwidth768.css" rel='stylesheet'>
<link href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/maxwidth600.css" rel='stylesheet'>
Run Code Online (Sandbox Code Playgroud)

媒体查询所有人:

maxwidth959.css

 @media only screen and (max-width: 959px)
 {
   // styles here
 }
Run Code Online (Sandbox Code Playgroud)

maxwidth768.css

@media only screen and (max-width: 768px)
{
  // styles here
}
Run Code Online (Sandbox Code Playgroud)

maxwidth600.css

@media only screen and (max-width: 600px)
{
    // styles here
}
Run Code Online (Sandbox Code Playgroud)

但只有最后一个链接的CSS(maxwidth600.css)CSS正在生效,其他人是否重写?

html css php

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

使用fscanf从文件读取数据后程序崩溃

我编写了一个简单的程序来读取文本文件的内容,然后用cl.exe(visual studio编译器)编译它.程序编译,当我运行它时,它正常启动,当它超过读取和打印数据时,它会残酷地崩溃......这是代码:

#include <iostream> 
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <fstream>
#include <string>


int main (int argc, char *argv[]) 
{
char filename[256];
char d1[9]; 
char d2[8];

if (argc > 1) //lecture de l'argument
strcpy(filename, argv[1]);
    else {
        printf("Usage: read_file");
        return 0;
    }

FILE *f = fopen(filename, "r");
if (f == NULL) {
  printf("Cannot find file \'%s\'\n", filename);
  return 0;
}

printf("file opened\n");

rewind(f);
fscanf(f, "%s %s", d1, d2);

printf("%s %s",d1,d2);
fclose(f);

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

当我用gcc编译它时它工作得很好.问题是,我需要使用visual studio编译器运行...

c++ visual-c++

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

在 C++ 中使用 while 循环未通过测试用例

我的需求:

使用 while 循环迎接尽可能多的名称在标准输入中可用。当您将字符串 '42' 作为名称读取时停止。

我的编码:

#include<iostream>
using namespace std;
int main()
{
    int input=1;
    int i= 0;
    string name;
    while(input<=i)
    {
        cin>>name;
        if(name=="42")
        {
             break;
        }
        else
        {
           cout<<"Hello "<<name<<"!";
           i++;
        }

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

结果:

对于输入 42,测试用例通过。对于其他输入,测试用例失败。请发布您的答案。

大约 1 年后回答:

非常抱歉这个问题。这是我在对 C++ 了解 0 时问的问题。这可能对新生有用。

c++ while-loop testcase

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

"" 或" - >"C struct accessor

"."之间有什么区别?访问C结构中的数据时," - >"?我几次尝试都找不到任何区别.两者都为我提供了对欲望数据的访问

c struct accessor operators

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

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

Why won't clang compile this source code that works in VS2012?

I don't know if I'm doing something wrong here, but I can't for the life of me get clang to compile existing code that compiles fine in VS2012.

Includes like strsafe.h and xstring cause weird compilation errors, the strangest of which is a "missing close bracket" in the middle of a standard include file. Needless to say, there is no missing bracket. Further, move.h causes clang to throw up with

fatal error: expected function body after function declarator.

Guard …

c++ compiler-errors clang

-46
推荐指数
2
解决办法
1944
查看次数

单层神经网络

对于单层神经网络的实现,我有两个数据文件.

In:
    0.832 64.643
    0.818 78.843

Out:
    0 0 1
    0 0 1
Run Code Online (Sandbox Code Playgroud)

以上是2个数据文件的格式.

目标输出为"1表示相应输入所属的特定类,"0表示其余2个输出.

问题如下:

您的单层神经网络将在Y = A*X + b中找到A(3乘2矩阵)和b(3乘1矢量),其中Y是[C1,C2,C3]',X是[x1,x2]' .

为了用神经网络解决上述问题,我们可以重新编写如下公式:Y = A'*X'其中A'= [A b](3乘3矩阵),X'是[x1,x2, 1]"

现在您可以使用具有三个输入节点(分别用于x1,x2和1)和三个输出(C1,C2,C3)的神经网络.

由此产生的9(因为我们在3个输入和3个输出之间有9个连接)权重将等同于A'矩阵的元素.

基本上,我试图做这样的事情,但它不起作用:

function neuralNetwork   
    load X_Q2.data
    load T_Q2.data
    x = X_Q2(:,1);
    y = X_Q2(:,2);

    learningrate = 0.2;
    max_iteration = 50;

    % initialize parameters
    count = length(x);
    weights = rand(1,3); % creates a 1-by-3 array with random weights
    globalerror = 0;
    iter = 0;
    while globalerror ~= 0 && iter <= max_iteration …
Run Code Online (Sandbox Code Playgroud)

matlab artificial-intelligence classification perceptron

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

为什么i | = j | = k | =(j + = i) - - (k +++ k) - - (i = + j)== 11?

我在一个我开始研究的项目中遇到了这段代码.最初的开发人员已经不再可用,我无法理解它.

k = (j = (i = 0) + 2) + 1;
return i|= j|= k|= (j+= i) - - (k+++k) - - (i =+j);
Run Code Online (Sandbox Code Playgroud)

它产生的价值11.这是如何运作的?

什么是=+运营商?

什么是+++运营商?

什么是- -运营商?

什么是|=运营商?

java operators operator-precedence

-80
推荐指数
4
解决办法
2万
查看次数