小编tek*_*agi的帖子

HTML/CSS/JS:隐形表单是否可以拦截(劫持)用户输入?

我听到有人提到理论上可以在内容之上放置一个不可见的iframe,并接收某人想要放入表单的输入.这怎么可能而且不会引起怀疑?吓到我了...

html javascript css security iframe

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

pyparsing问题

现在我刚刚开始使用pyparsing解析简单的后缀表达式.目前,我得到了这个:

from pyparsing import *
integer = Word(nums)
op = Word("+-*/^", max=1)
space = Word(" ")
expr = Word(nums)+space+Word(nums)+space+op
parsed = expr.parseString("3 4 *")
print parsed
Run Code Online (Sandbox Code Playgroud)

但是当我运行它时,它会打印:

Traceback (most recent call last):
  File "star_parse.py", line 6, in <module>
    parsed = expr.parseString("3 4 *")
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyparsing-1.5.5-py2.6.egg/pyparsing.py", line 1100, in parseString
    raise exc
pyparsing.ParseException: Expected W:( ) (at char 2), (line:1, col:3)
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

python parsing expression pyparsing postfix-operator

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

继续在bash中运行进程/刷新

我想要关注特定命令的输出ps aux | grep guest.

我在等它改变.有什么方法可以做一些像tail命令对文件做的事情吗?

马克斯

bash process tail

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

蟒蛇和回文

我最近写了一个方法来循环/usr/share/dict/words并使用我的ispalindrome(x)方法返回一个回文列表这里的一些代码......它有什么问题?它只会停顿10分钟,然后返回文件中所有单词的列表

def reverse(a):
    return a[::-1]

def ispalindrome(a):
    b = reverse(a)
    if b.lower() == a.lower():
        return True
    else:
        return False

wl = open('/usr/share/dict/words', 'r')
wordlist = wl.readlines()
wl.close()
for x in wordlist:
    if not ispalindrome(x):
        wordlist.remove(x)
print wordlist

python arrays file list palindrome

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

关于C库的新手问题

在Windows XP上启动C并进行开发...我包含的库(如果是个人库)必须在某个目录中吗?或者将计算机的内容编入索引以找到它们?

谢谢

c header

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

在Python中考虑二次多项式

因为在我的头脑中分解二次方程只是发生了,并且自从我学会了之后就已经这样做了 - 我将如何开始在Python中编写二次方因子?

python math quadratic factorization

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

用星号填充形状

我写了一个程序来用星号填充封闭的数字。

出于某种原因,它不接受哨兵值EOF Ctrl+ D

为什么是这样?

#include "usefunc.h"

#define height 100
#define width 100

void showRow(int numbers[], int size_numbers) {
    int i;
    printf("[ ");
    for (i = 0; i &lt; size_numbers-3; i++) {
        printf("%c, ", numbers[i]);
  }
    printf("%c ]", numbers[size_numbers-3]);
    printf("\n");
}

void showshape(int shape[][width], int lines, int max_buf) {
    int i, j;
    for (i = 0; i &lt; lines; i++) {
        for (j = 0; j &lt; max_buf; j++) {
            printf("%c", shape[i][j]);
        }
        printf("\n");
    }
}

void …
Run Code Online (Sandbox Code Playgroud)

c shapes eof

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

在javascript中替代if,else if,else if,else if等

我有以下代码,这取决于url参数更改,然后隐藏表单上的选择选项.即www.example.com?type=images

最终将有超过20个不同的参数.我想知道一个更好的方法,而不是拥有大量的elses.只是概述了如何做到这一点很好,我是新手,所以我希望能够得到答案并从中学习.谢谢.

var type = getURLparameter('type'); //from another function

if (type == "images"){
    var selectDiv =('divid');
    var selectField = ('selectid');
    document.getElementById(selectField).options[1].selected=true;
    document.getElementById(selectDiv).style.visibility="hidden";
}
else if (type == "pizza") {
    var selectDiv =('divid');
    var selectField = ('selectid');
    document.getElementById(selectField).options[2].selected=true;
    document.getElementById(selectDiv).style.visibility="hidden";
}
else (type == "cheese") {
    var selectDiv =('divid');
    var selectField = ('selectid');
    document.getElementById(selectField).options[3].selected=true;
    document.getElementById(selectDiv).style.visibility="hidden";
}
Run Code Online (Sandbox Code Playgroud)

javascript if-statement switch-statement

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

匹配Haskell类型类中的类型

如果有人有一个好名字,我不知道怎么说这个,请告诉我.

我正在尝试编写一个名为的类类Matchable.这个想法是我有几种不同类型的正则表达式(RegExp a,ComplexRegex a)应该能够在输入上匹配.

所以我尝试了这个:

class Matchable a where
  --   regex, input, success
  match :: a -> b -> Bool
Run Code Online (Sandbox Code Playgroud)

但我真正想要的是用类型构造函数或其他东西来解构类型类中的构造函数:

class Matchable a where
  --   regex, input, success
  match :: (B a) -> [a] -> Bool
Run Code Online (Sandbox Code Playgroud)

这样我就能得到一个RegExp CharComplexRegex Char两个匹配String.有没有办法做到这一点?谢谢.

haskell typeclass

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

打印任意数量的浮点数

如何float在python中打印超过10位数的数字?现在,什么时候做

print sqr_newton(10, 3, 0.001) (其中sqr_newton是newton的平方根算法;返回一个浮点数)

它只在小数位后给出这么多数字......我怎样才能得到更多?

python algorithm floating-point newtons-method square-root

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