我想通读二进制文件.谷歌搜索"python二进制eof"引领我到这里来.
现在,问题:
read(1)方法读取文件时检测EOF ?我使用jQuery UI Tabs.我在每个新标签中都有一个DataTable.我想将对话框中选中的行添加到当前选项卡中的表.
因为我在选项卡中的那些表用我用于制表符的相同编号命名(例如"tabs-1"将包含表"choice1")我宁愿每次需要添加行时找到所需的表而不是存储所有那些表集合中的变量.
如果您确切地知道在初始化时访问已经初始化的DataTables而不存储在变量中是不可能的,请建议一种存储方法,因为我唯一想到的是一个对象,其中键是包含制表符名称的字符串值是表变量.而且我不确定这是最好的方式.
这是我现在尝试的:
var id = '#choice' + $("#tabs ul>li a").eq(tabs.tabs('option', 'active')).attr('href').slice(-1);
$(id).row.add( dialogTable.rows({ selected: true }).data() ).draw();
Run Code Online (Sandbox Code Playgroud)
所以,即使我评论第一行和硬编码"#choice1",它仍然会产生错误TypeError: $(...).row is undefined.
当要编辑一行时,索引会传递到编辑对话框中。
编辑工作正常。
当我想添加一行时,我不会将索引传递给对话构造函数,因此它知道应该添加新行。
这是对对话框按钮做出反应的函数代码
void DialogAddCl::on_buttonBox_clicked(QAbstractButton *button)
{
// prepare
m->database().transaction();
QString debugstr;
auto chi4 = ui->buttonBox->buttonRole(button);
int rowCount = m->rowCount();
switch (chi4) {
case QDialogButtonBox::AcceptRole:
if (!ind->isValid())
// insert
if (!m->insertRow(rowCount, *ind))
{
QMessageBox::critical (this, "Error inserting into model", m->lastError().text(), QMessageBox::Cancel);
break;
}
else
{
m->setData(m->index(rowCount, 0), rowCount+1);
}
else
{
// update
rowCount = ind->row();
}
m->setData(m->index(rowCount, 1), ui->name->text());
m->setData(m->index(rowCount, 2), ui->addr->text());
// 12 other setData() calls
if (m->submitAll())
{
m->database().commit();
}
else
{
// rollback if error …Run Code Online (Sandbox Code Playgroud) 我想获取字符串的最后一个字符。我可以使用len方法打印它来获取它,但是在使用非常相同的方法获取它时我无法将它与另一个字符进行比较。现在我将把这个WTF代码粘贴在这里。请告诉我这里发生了什么。
fields = line.split(';')
last = fields[0]
capacity = fields[1]
region = fields[2]
print(capacity)
print('kek')
print(capacity[len(capacity)-1])
print('even more kek')
while capacity[len(capacity)-1] == '0':
capacity = capacity[1:len(capacity)-2]
last = last[1:len(last)-2]
Run Code Online (Sandbox Code Playgroud)
现在,输出
100000
kek
0
even more kek
Traceback (most recent call last):
File "/home/mekkanizer/?????????/proj/rossvyaz/making_insert_queries.py", line 52, in <module>
while capacity[len(capacity)-1] == '0':
IndexError: string index out of range
Run Code Online (Sandbox Code Playgroud)