标签: syntax

for循环中无法解释的语法错误

我在这里的第二行到最后一行遇到了语法错误,但不知道为什么.它看起来与它之前的第2行相同,但由于某种原因我得到了语法错误.我已经尝试过它和它之前的线和它之间的空行,结果相同.

## numlist = some list
array_size = 20
for row in xrange(array_size):
    for col in xrange(array_size):
        if(col<=(array_size-4)):
            check(sum(numlist[row][col:col+4])
        if(row<=(array_size-4)):
            check(sum([numlist[row+i][col] for i in range(4)]))
Run Code Online (Sandbox Code Playgroud)

python syntax

-3
推荐指数
2
解决办法
221
查看次数

如果语句后跟循环

if语句有一定的条件然后我在if语句中使用while循环和另一个条件,if语句中的条件是否会在每次迭代中被测试?

LIST-SEARCH'(L,k)
x=L.nil.next
if x!=L.nil
   while x.key!=k
         x=x.next
return x
Run Code Online (Sandbox Code Playgroud)

syntax scope pseudocode

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

语法错误它可能是什么?

我一直试图运行这个程序一段时间但我似乎无法找出在尝试运行它时导致错误的原因.

这是我收到错误的代码行:

from math import *
from myro import *
init("simulator")

def rps(score):
    """ Asks the user to input a choice, and randomly assigns a choice to the computer."""
    speak("Rock, Paper, Scissors.")
    computerPick = randint(1,3)
    userPick = raw_input("Please enter (R)ock, (P)aper, or (S)cissors.")
    if userPick = R <#This line is where the error shows up at>
        print "You picked rock."
    elif userPick = P
        print "You picked paper."
    else
        print "You picked Scissors."
    score = outcome(score, userPick, computerPick)
    return score
Run Code Online (Sandbox Code Playgroud)

python syntax

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

关键字"FROM"和"AS"附近的语法不正确

string sqlQueryString = " SELECT g.code AS GoodCode, g.name AS GoodName, " +
"msr.name AS MsrName, sm.min_quan AS KolMin, sm.max_quan AS KolMax, " +
"sm.quan AS KolNal, ord.prc AS EdPrice, s.name AS Sklad, m.name AS Mol, " +
"k.code AS KodDost, k.name AS NameDost " +
"FROM N_GOODS_{0} AS g INNER JOIN " +
"G_SMGS_{0} AS sm ON g.id = sm.good_id INNER JOIN " +
"N_KNTRS_{0} AS k ON g.id = k.id INNER JOIN " +
"N_PRC_LISTS_{0} AS pr ON …
Run Code Online (Sandbox Code Playgroud)

c# sql-server syntax

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

想写一个IF条件声明

如何用DOG语言编写IF条件语法.我不知道如何编写条件语法.有任何想法吗.IF

syntax if-statement esoteric-languages dog

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

这是在c ++中运行循环的有效方法吗?

如果我想要一个while循环:虽然变量不等于几个不同的值,这是否有效?:

while (uInput != ('a' || 'b' || 'c')){
    //do something to make it equal one of those
}
Run Code Online (Sandbox Code Playgroud)

或者我是否必须单独将uInput与a,uInput与b进行比较,依此类推?

c++ syntax loops while-loop

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

read命令的第二个参数是什么意思?

我有这个Python代码:

for name, age in read(file, ('name','age')):
Run Code Online (Sandbox Code Playgroud)

有人可以解释一下它的意思吗?

python io syntax

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

C#代码允许有趣的语法,而且void方法也允许返回

大家好昨天我发了一个问题:像c#allow; ; ; ; ; ; ; ; ; ; ; ; (C#空声明)

为什么C#允许这个有趣?; ; ; ;

并找到答案:https://stackoverflow.com/a/20551989/2218635

但是今天我又看到了一个有趣的(bug)

见下图

在此输入图像描述

为什么visual studio允许这个?代码构建成功.为什么要构建?

另一个有趣的代码总是运行

private void install()
    {
        http://www.stackoverflow.com
        return;
    }
Run Code Online (Sandbox Code Playgroud)

编辑:

看上面的方法是一个void方法,我知道void方法不返回.但为什么没有显示任何错误?而且我没有为" http://www.stackoverflow.com " 指定任何变量.但为什么它不会给我一个错误?

c# syntax return visual-studio

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

运行脚本时出现Python错误 - "IndentationError:unindent与任何外部缩进都不匹配"

我尝试运行脚本时收到错误

Error:"IndentationError: unindent does not match any outer indentation"
Run Code Online (Sandbox Code Playgroud)

抛出错误的代码snipet:

def update():
    try:
        lines = open("vbvuln.txt", "r").readlines()
    except(IOError): 
         print "[-] Error: Check your phpvuln.txt path and permissions"
         print "[-] Update Failed\n" 
        sys.exit(1)
    try:
Run Code Online (Sandbox Code Playgroud)

这是出现错误的实际行:

print "[-] Update Failed\n" 
Run Code Online (Sandbox Code Playgroud)

python syntax indentation

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

我看到了这个节目.这是什么 - 在构造函数复数(double r,double i)之后的re(r),im(i){}?

// operator_overloading.cpp
// compile with: /EHsc
#include <iostream>
using namespace std;

struct Complex {
   Complex( double r, double i ) : re(r), im(i) {} // what is this syntax?
   Complex operator+( Complex &other );
   void Display( ) {   cout << re << ", " << im << endl; }
private:
   double re, im;
};

// Operator overloaded using a member function
Complex Complex::operator+( Complex &other ) {
   return Complex( re + other.re, im + other.im );
}

int main() { …
Run Code Online (Sandbox Code Playgroud)

c++ syntax

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