小编And*_*ndy的帖子

.click似乎没有解雇......为什么?

我试图获得一个链接来解雇JQuery的.click()函数,以便我可以在幕后调用另一个脚本.所有的JQuery都是由PHP动态生成的.

代码看起来正确,但.click没有触发.

这是生成jquery的代码:

            $jscript = "$(\"".$server ."Restart\").click(function()
            {
                $.get(\"modules/test.php\", {command: \"RESTART\", server: \"$server\"},
                    function(data){
                        alert(\"Data Sent: \" + data);
                    }
                );
            });
            ";
Run Code Online (Sandbox Code Playgroud)

这是代码,因为它照顾生成(现在只提醒,因为我不能让它做任何事情):

$("critRestart").click(function()
            {
                $.get("modules/test.php", {command: "RESTART", server: "crit"},
                    function(data){
                        alert("Data Sent: " + data);
                    }
                );
            });
Run Code Online (Sandbox Code Playgroud)

这是点击的应该触发该事件的链接: <div id="critRestart"><a href="#">RESTART</a></div>

有人可以帮忙吗?

php jquery

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

Elif给出了无效的语法python?

这是我一直在使用的代码,但它没有工作,因为它说elif语句是无效的语法.任何人都可以帮助我,因为我是python的初学者.

age = int(input('How old are you?: '))
if age <= 16:
    print ('You are too young to enter this section of the program!')
else:
    age >= 16
    print ('Welcome to the advanced section of the program!')

elif: password = int(input('please enter the password to enter the elite members section: ')):
    if password == ('muffin'):
        print ('Well done for unlocking the secret part of the program')
    else:
            print ('You shall not pass!')
Run Code Online (Sandbox Code Playgroud)

python

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

我真的需要关闭文件吗?如果是这样,为什么以及如何?

代码取自"学习Python艰难之路"练习17,但我稍微调整了一下,所以我问这个问题:


from sys import argv
from os.path import exists

script, file1, file2 = argv

print "Copying from %s to %s:" % (file1, file2)

indata = open(file1).read()

print "The input file is %d bytes long" % len(indata)

print "Does the output file exist? %r" % exists(file2)

outdata = open(file2, 'w').write(indata)
Run Code Online (Sandbox Code Playgroud)

当我添加行:

file1.close()
file2.close()
Run Code Online (Sandbox Code Playgroud)

在此代码的末尾.我在终端上获得输出:

从python/test.txt复制到python/sampleout.txt:

The input file is 18 bytes long
Does the output file exist? True
Traceback (most recent call last):
  File "python/myprogram0.py", line 16, in <module>
    file1.close()
AttributeError: …
Run Code Online (Sandbox Code Playgroud)

python

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

Python帮助"***关键字不能表达"错误

我使用python 2.7.8 64位.我正在尝试使用numpy包导入CSV文件.我一直得到***关键字不能表达,然后它给我路径并说第6行,所以我假设第6行是问题所在.

这是我的代码.

import numpy as np

def main():

    try:
        date, rate, arb = np.loadtext('TutSheet.csv'.
                                    delimter=',',
                                    unpack=True,
                                    dtype='str')

        print date

    except Exception, e:
            print str(e)
Run Code Online (Sandbox Code Playgroud)

python numpy

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

标签 统计

python ×3

jquery ×1

numpy ×1

php ×1