我创建了一个javascript函数,它从div样式中获取两个图像,并在指定时间后首先显示一张图片,另一张图片显示.
JavaScript的
var imageID = 0;
function changeImage (every_seconds) {
if (!imageID) {
document.getElementById("myimage1");
imageID++;
}
if (imageID == 1) {
document.getElementById("myimage2");
}
}
//call same function again for x of seconds
setTimeout("changeImage(" + every_seconds + ")", ((every_seconds) * 50000000000));
}
Run Code Online (Sandbox Code Playgroud)
HTML
<body style='background:black;' onload='changeimage(10)'>
<div style='position:absolute;width:100%;height:100%;left:0px;top:0px;' align='left'>
<img width='600px' height='500px' id='myimage1' src='http://www.photos.a-vsp.com/fotodb/14_green_cones.jpg'/>
</div>
<div style='position:absolute;width:100%;height:100%;left:0px;top:0px;' align='right'>
<img width='600px' height='500px' id='myimage2' src='http://www.hickerphoto.com/data/media/186/flower-bouquet-nice_12128.jpg'/>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
请有人可以帮助如何一次只获取一个图像,并以指定的间隔消失另一个图像.
我试图匹配以char'*'开头的行.文件mac-address.txt如下:
Legend: * - primary entry
age - seconds since last seen
n/a - not available
vlan mac address type learn age ports
------+----------------+--------+-----+----------+--------------------------
* 14 782b.cb87.b085 dynamic Yes 0 Gi4/39
* 400 c0ea.e459.913d dynamic Yes 0 Gi6/21
* 400 0017.c59a.23aa dynamic Yes 0 Gi3/37
* 400 d4be.d96a.050f dynamic Yes 0 Gi1/12
Run Code Online (Sandbox Code Playgroud)
我有这样的工作.
#!/usr/bin/perl
use strict;
use warnings;
my $line;
open FH, '<', "mac-address.txt";
while ($line = <FH>)
{
if ($line =~ m/^\S/){
print ("$line");
}
}
close FH;
Run Code Online (Sandbox Code Playgroud)
但它与一些不需要的行一起工作如下: …
我有OSX Yosemite 10.10和Intel i5处理器.我安装了Android SDK和Eclipse.它的工作原理但问题是,当我创建AVD启动它时,它会显示以下错误:
Starting emulator for AVD 'Nexus4-18-xhdpi'
emulator: ERROR: x86 emulation currently requires hardware acceleration!
Please ensure Intel HAXM is properly installed and usable.
CPU acceleration status: HAX is not installed on this machine (/dev/HAX is missing).
Run Code Online (Sandbox Code Playgroud)
我是android编程的新手,并不知道如何解决它或查看/ dev/Hav.请帮忙.谢谢.
我有一个脚本,它从CLI中获取3个输入变量并分别将它插入3个变量:
GetOptions("old_path=s" => \$old_path,
"var=s" => \$var,
"new_path=s" => \$new_path,
"log_path=s" => \$log_path)
or die ("Error in input variables\n");e
Run Code Online (Sandbox Code Playgroud)
有没有一种方法可以添加子程序或任何其他GetOptions参数来解释如何给出输入变量.如果有任何错误,请纠正我.谢谢.
我有一个日志文件,如下所示:
4680 p4exp/v68 PJIANG-015394 25:34:19 IDLE none
8869 unnamed p4-python R integration semiconductor-project-trunktip-turbolinuxclient 01:33:52 IDLE none
8870 unnamed p4-python R integration remote-trunktip-osxclient 01:33:52
Run Code Online (Sandbox Code Playgroud)
在同一个日志文件中有许多这样的条目,有些条目在末尾包含IDLE,而有些则不包含.我想保留散列中具有"R integration"和"IDLE none"的那些并忽略其余部分.我尝试了以下代码,但没有得到所需的结果.
#!/usr/bin/perl
open (FH,'/root/log.txt');
my %stat;
my ($killid, $killid_details);
while ($line = <FH>) {
if ($line =~ m/(\d+)/){
$killid = $1;
}
if ($line =~ /R integration/ and $line =~ /IDLE none/){
$killid_details = $line;
}
$stat{$killid} = {
killid => $killid_details
};
}
close (FH);
Run Code Online (Sandbox Code Playgroud)
我得到R集成的所有行(例如我得到8869,8870行),因为8870应该被忽略,所以不应该这样.
如有任何错误,请通知我.我还在学习perl.谢谢.
我正在使用GetOpt :: long模块从命令行获取参数并将其分配给相应的变量.但是我在打印时遇到错误.代码和错误如下:
#!usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
GetOptions(
"mount_path=s" => \my $old_path,
"var=s" => \my $var,
"log_path=s" => \my $log_path,
) or die "Error in input variables\n";
print <<"END_INPUTS";
These are your inputs:
old_path= $old_path
var = $var
log_path=$log_path
Press enter twice if all looks GOOD
*********************************************************
END_INPUTS
Run Code Online (Sandbox Code Playgroud)
命令行参数如下:
perl getvar.pl --mount_path=/var/sslvpn --var=7.0.0.2_va-SSLVPN-!7.0.0.2.16sv+.jpn-05!j+g_554863- --log_path=log.txt
Run Code Online (Sandbox Code Playgroud)
我在运行时遇到以下错误
-bash: !7: event not found
Run Code Online (Sandbox Code Playgroud)
请有人帮我这个.谢谢.
我有一个脚本,它使用 pexpect telnet 到交换机并将其运行配置复制到 tftp 服务器。如果我给出主机名,那么脚本可以正常工作,但是在 pexect 中使用正则表达式时,会发生超时。代码如下:
child = pexpect.spawn('telnet ' +ip)
child.expect ('Login: ')
child.sendline (username)
child.expect ('Password: ')
child.sendline (password)
child.sendline ('enable')
child.expect('Password: ')
child.sendline(password)
child.expect('.*\-.*#')
child.sendline ('copy running-config tftp://10.0.37.111/'+filename+'.txt')
time.sleep(5)
Run Code Online (Sandbox Code Playgroud)
我将上述正则表达式作为我当前交换机的主机名是 Force10-60。谢谢。
我试图在python中排序列表列表.我写了以下代码:
def sort(intervals):
if intervals == [] : return []
intervals.sort(key = lambda x:x.start)
return intervals
a = [[1,3],[8,10],[15,18],[2,6]]
print(sort(a))
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
AttributeError: 'list' object has no attribute 'start'
Run Code Online (Sandbox Code Playgroud)
请有人解释lambda函数的排序和一些有关上述错误的细节.谢谢!!
我正在学习RESTFUL API,而我遇到的问题是只发出GET请求但POST请求失败.代码在这里:
from flask import Flask, request
app = Flask(__name__)
#Make an app.route() decorator here
@app.route("/puppies", methods = ['GET', 'POST'])
def puppiesFunction():
if request.method == 'GET':
#Call the method to Get all of the puppies
return getAllPuppies()
elif request.method == 'POST':
#Call the method to make a new puppy
return makeANewPuppy()
def getAllPuppies():
return "Getting All the puppies!"
def makeANewPuppy():
return "Creating A New Puppy!"
if __name__ == '__main__':
app.debug = True
app.run(host='0.0.0.0', port=5000)
Run Code Online (Sandbox Code Playgroud)
GET请求工作正常但POST请求中出现错误.错误是:
127.0.0.1 - - [20/May/2016 01:39:34] …Run Code Online (Sandbox Code Playgroud) 我理解以下代码,以查找字符串是否是同构的.该代码使用两个散列s_dict和t_dict分别.我假设字符串长度相同.
def isIsomorphic(s, t):
s_dict = {}
t_dict = {}
for i in range(len(s)):
if s[i] in s_dict.keys() and s_dict[s[i]] != t[i]:
return False
if t[i] in t_dict.keys() and t_dict[t[i]] != s[i]:
return False
s_dict[s[i]] = t[i]
t_dict[t[i]] = s[i]
return True
Run Code Online (Sandbox Code Playgroud)
现在,如果我修改上面的代码,只使用一个哈希s_dict(),那么它也会给我有限的测试用例提供所需的结果.修改后的代码如下:
def isIsomorphic(s, t):
s_dict = {}
for i in range(len(s)):
if s[i] in s_dict.keys() and s_dict[s[i]] != t[i]:
return False
s_dict[s[i]] = t[i]
return True
Run Code Online (Sandbox Code Playgroud)
上述修改代码失败的测试用例是什么?我对同构字符串的理解是错误的吗?
最近,我得到了一个面试问题,即将"1 + 2-3"和"-2 + 4"等字符串表达式分别转换为0和2.假设输入是单位数字后跟符号而没有NULL输入.我试过这个输出,但面试官说我很接近但不是完美的解决方案.请帮帮我.谢谢.
def ans(input):
result, j = 0, 0
for i in input:
if i == '+' or i == '-':
j = i
else:
i = int(i)
result = result j i
return result
ans("1+2-3")
ans("-2+4")
Run Code Online (Sandbox Code Playgroud)
我犯了一些愚蠢的错误,但我正在学习.提前致谢.
python ×5
perl ×4
regex ×3
getopt-long ×2
android ×1
css ×1
dictionary ×1
flask ×1
getopt ×1
hash ×1
html ×1
if-statement ×1
intel ×1
javascript ×1
lambda ×1
linux ×1
macos ×1
pexpect ×1
rest ×1
string ×1