你好,我有一个输入文件,我喜欢输入样式,没有标签和ID就无法获得它
我花了几个小时解决了它,我只想知道还有更好的解决方案吗?
Traceback (most recent call last):
File "<ipython-input-94-453876631fe0>", line 3, in <module>
data_df = pd.read_sql(sql, qq)
File "***\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\sql.py", line 380, in read_sql
chunksize=chunksize)
File "***\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\sql.py", line 1468, in read_query
cursor = self.execute(*args)
File "***\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\sql.py", line 1426, in execute
cur = self.con.cursor()
TypeError: 'pyodbc.Cursor' object is not callable
答案 0 :(得分:1)
此代码段中的所有内容:
// keeping track of IDs
let id = 1
// create item to be appended
const addFileInput = (id) => {
// creating base node that will be returned
const node = document.createElement('div')
// setting classes on base node
node.classList.add('custom-file', 'mb-3')
// creating innerHTML of node
node.innerHTML = `<input type="file" name="filename[]" id="${id}">
<button class="btn btn-${id === 1 ? 'success' : 'danger'}" type="button">${id === 1 ? '+' : '-'}</button>
<label class="custom-file-label" for="${id}">Choosse file</label>`
// returning the node
return node
}
// append the first input field (type: node)
const container = document.getElementById('field-container')
container.appendChild(addFileInput(id))
// functions for onClick
$(document).ready(function() {
$(container).on("click", ".btn-success", function() {
// incrementing the ID BEFORE appending
container.appendChild(addFileInput(++id))
});
$(container).on("click", ".btn-danger", function() {
// removing the exact element
$(this).parents('.custom-file').remove();
});
});
.control-group .custom-file {
width: 300px;
display: flex;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<div id="field-container" class="control-group">
<!-- will be filled out by JavaScript -->
</div>
此代码似乎并不比您的代码简单,但可以轻松修改