小编bha*_*nsa的帖子

从更改时选择中获取选定的值/文本

<select onchange="test()" id="select_id">
    <option value="0">-Select-</option>
    <option value="1">Communication</option>
</select>
Run Code Online (Sandbox Code Playgroud)

我需要在javascript中获取所选选项的值:有没有人知道如何获取所选值或文本,请告诉我们如何为它编写函数.我已经分配了onchange()函数来选择那么我之后做了什么?

javascript

63
推荐指数
12
解决办法
40万
查看次数

将多个文件连接到单个文件对象中,而无需创建新文件

这个问题与Python连接文本文件有关

我有一个清单file_names,比如['file1.txt', 'file2.txt', ...].

我想将所有文件打开成一个文件对象,我可以逐行阅读,但我不想在这个过程中创建一个新文件.那可能吗?

with open(file_names, 'r') as file_obj:
   line = file_obj.readline()
   while line:
       ...
Run Code Online (Sandbox Code Playgroud)

python file

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

如何仅在css中模糊背景图像

嗨,我想模糊背景图像,但我认为它缺乏这样做.对它的任何帮助都会增加我的能量.谢谢

这是我的CSS

html {
  position: relative;
  min-height: 100%;
  max-width:  100%;
   background: url(img/rsz_1spring.jpg);
   background-repeat: no-repeat;
   -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
 max-width: 100%;
    overflow-x: hidden;

}
Run Code Online (Sandbox Code Playgroud)

我正在尝试应用此功能,但它模糊了我的所有网页仅包含背景图像.

-webkit-filter: blur(5px);
-moz-filter: blur(5px);
-o-filter: blur(5px);
-ms-filter: blur(5px);
filter: blur(5px);
Run Code Online (Sandbox Code Playgroud)

谢谢.

html css

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

使用灯塔在gulp中生成HTML报告

我正在使用gulp进行项目,我在这个gulp任务中添加了灯塔:

gulp.task("lighthouse", function(){
    return launchChromeAndRunLighthouse('http://localhost:3800', flags, perfConfig).then(results => {
      console.log(results);
    });
});
Run Code Online (Sandbox Code Playgroud)

这是我的launchChromeAndRunLighthouse()函数

function launchChromeAndRunLighthouse(url, flags = {}, config = null) {
  return chromeLauncher.launch().then(chrome => {
    flags.port = chrome.port;
    return lighthouse(url, flags, config).then(results =>
      chrome.kill().then(() => results));
  });
}
Run Code Online (Sandbox Code Playgroud)

它在命令行中为我提供了json输出.我可以在这里发布我的json 并获得报告.

有什么办法可以使用gulp生成HTML报告吗?

如果您认为这个问题对未来的读者有帮助,欢迎您开始赏金.

google-chrome lighthouse gulp

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

预加载字体很棒

我正在尝试预加载font-awesome以改善我的页面加载时间:

<link rel="preload" as="style" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"/>
<link rel="preload" as="font" type="font/woff2" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/fonts/fontawesome-webfont.woff2?v=4.3.0"/>
Run Code Online (Sandbox Code Playgroud)

但是...... Chrome似乎下载了两次字体并报告

资源 http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/fonts/fontawesome-webfont.woff2?v=4.3.0 是使用链接预加载预加载的,但是在窗口加载事件的几秒钟内没有使用.请确保没有预装任何东西.

在此输入图像描述 我如何让它工作?

preload font-awesome

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

如何在bootstrap模态体上创建一个带有固定标题的可滚动表?

我尝试这个,但这不起作用.字段值是动态来的.所以宽度不固定.

<div class="table-responsive">

    <table class="table table-hover">
  <thead>

      <tr>
     ...

      </tr>
    </thead>

    <tbody style="height:100px;overflow-y:scroll;">
     <tr>
      ...
      </tr>
   </tbody>
    </table>
</div>
Run Code Online (Sandbox Code Playgroud)

html javascript css jquery

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

将具有常量参数的函数应用于熊猫数据框

我有一个熊猫数据框,我创建了一个函数。我想将此函数应用于数据帧的每一行。然而,该函数有第三个参数,它不是来自数据帧,可以说是常数。

import pandas as pd

df = pd.DataFrame(data = {'a':[1, 2, 3], 'b':[4, 5, 6]})

def add(a, b, c):
    return a + b * c

df['c'] = add(df['a'], df['b'], 2)
Run Code Online (Sandbox Code Playgroud)

我想我必须使用 apply 函数,但我不知道如何传递这个常量参数。

print df
>>    a  b   c
>> 0  1  4  10
>> 1  2  5  14
>> 2  3  6  18
Run Code Online (Sandbox Code Playgroud)

python apply pandas

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

向球体添加渐变颜色

我想为球体添加渐变颜色,目前我正在设置颜色:

<a-sphere position="1 1 0" color="#ef2d5e">
    <a-animation attribute="rotation" to="0 360 0" dur="10000" easing="linear" repeat="indefinite">
    </a-animation>
</a-sphere>
Run Code Online (Sandbox Code Playgroud)

演示

如何向球体添加渐变?有什么办法。

aframe

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

突出显示python中的文本并将其保存在word文件中

我正在尝试从 word 文件中获取文本并突出显示所需的文本,并且老化想要将文本保存到新的 word 文件中。

我能够使用 ANSI 转义序列突出显示文本,但我无法将其添加回 word 文件。

from docx import Document
doc = Document('t.docx')
##string present in t.docx '''gnjdkgdf helloworld dnvjk dsfgdzfh jsdfKSf klasdfdf sdfvgzjcv'''

if 'helloworld' in doc.paragraphs[0].text:    
    high=doc.paragraphs[0].text.replace('helloworld', '\033[43m{}\033[m'.format('helloworld'))


doc.add_paragraph(high)
doc.save('t1.docx')
Run Code Online (Sandbox Code Playgroud)

得到这个错误。

ValueError: All strings must be XML compatible: Unicode or ASCII, no NULL bytes or control characters
Run Code Online (Sandbox Code Playgroud)

python-3.x python-docx

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

如何在Javascript中添加P标签中的json值

点击一些标签,我正在创建para标签,我想添加一些文字.如何动态添加这些值.

这是我正在尝试的.

选项卡的onclick我正在调用此方法.

SomeMethod = function(){
    var para = document.createElement("P");
       para.setAttribute("id", "myUL");


    function getData(callback) {
        debugger;
        var httpRequest = new XMLHttpRequest();
        httpRequest.open('GET', "../resource/para.json", true);
        httpRequest.onreadystatechange = function() {
            if (httpRequest.readyState === XMLHttpRequest.DONE && httpRequest.status === 200) {
                callback(httpRequest.responseText);
            }
        };
        httpRequest.send();
    }

    getData(function(data) {
        var jsonc = JSON.parse(data);
        debugger;
   document.getElementById('myUL').innerHTML = jsonc[0].VALUE;
    });
}
Run Code Online (Sandbox Code Playgroud)

我的JSON数据是

[{
    "ID" : 0,
    "VALUE" : "My 10000 Character text."

    }]
Run Code Online (Sandbox Code Playgroud)

html javascript jquery

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