download = i.a.textmovie.append(download)
时间: 2024-06-07 09:07:12 浏览: 19
这是一行 Python 代码,其中 `i` 是一个对象,`a` 是这个对象的属性,`textmovie` 是 `a` 的一个属性,`append` 是一个方法,`download` 是作为参数传递给这个方法的值。
这行代码的作用是将变量 `download` 的值添加到 `i.a.textmovie` 这个属性中。具体的实现可能需要看上下文和具体的对象定义。
相关问题
# 查询按钮的回调函数 def query(self): # 检查日期是否填写 if not self.date_entry.get(): messagebox.showerror("Error", "未填寫日期.") return # 清空查询结果 for widget in self.result_text.winfo_children(): widget.destroy() # 获取所有查询条件 date = self.date_entry.get() name = self.line_entry1.get() name1 = self.line_entry2.get() # 查询数据 ws = openpyxl.load_workbook(r'D:\點檢系統存放資料夾\點檢明細\1.xlsx').active rows = ws.iter_rows(min_row=1, values_only=True) records = [] header = next(rows) for row in rows: if (not date or row[2] == date) and (not name or row[5] == name) and (not name1 or row[8] == name1): records.append(row) # 显示查询结果 table_frame = tk.Frame(self.result_text) table = ttk.Treeview(table_frame, columns=header, show='headings') table.pack(side=tk.LEFT, fill=tk.BOTH, expand=True) # 设置表格列标题 for col in header: table.heading(col, text=col) table.column(col, width=120) # 调整间隔距离 for row in records: table.insert('', tk.END, values=row) # 创建一个垂直滚动条并将其与表格关联 scrollbar = ttk.Scrollbar(table_frame, orient=tk.VERTICAL, command=table.yview) table.configure(yscrollcommand=scrollbar.set) scrollbar.pack(side=tk.RIGHT, fill=tk.Y) # 将表格和滚动条添加到一个框架中 table.pack(in_=table_frame, side=tk.LEFT, fill=tk.BOTH, expand=True) table_frame.pack(side=tk.LEFT, fill=tk.BOTH, expand=True) scrollbar.pack(in_=table_frame, side=tk.RIGHT, fill=tk.Y) download_button = ttk.Button(self.result_text, text="下載", command=lambda: self.download_excel(records)) download_button.pack(side=tk.BOTTOM)將這個代碼中下載按鈕滾動條的前面
可以尝试将下载按钮的创建代码放在滚动条之前,这样下载按钮就会出现在表格上方。修改后的代码如下:
```python
# 显示查询结果
table_frame = tk.Frame(self.result_text)
table = ttk.Treeview(table_frame, columns=header, show='headings')
table.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
# 设置表格列标题
for col in header:
table.heading(col, text=col)
table.column(col, width=120) # 调整间隔距离
for row in records:
table.insert('', tk.END, values=row)
download_button = ttk.Button(self.result_text, text="下載", command=lambda: self.download_excel(records))
download_button.pack(side=tk.BOTTOM)
# 创建一个垂直滚动条并将其与表格关联
scrollbar = ttk.Scrollbar(table_frame, orient=tk.VERTICAL, command=table.yview)
table.configure(yscrollcommand=scrollbar.set)
scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
# 将表格和滚动条添加到一个框架中
table.pack(in_=table_frame, side=tk.LEFT, fill=tk.BOTH, expand=True)
table_frame.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
scrollbar.pack(in_=table_frame, side=tk.RIGHT, fill=tk.Y)
```
def sample_data(filepath,idx,path): f = open(filepath, 'rb') bi = pickle.load(f) data = np.arange(0, idx) data = data.tolist() samples = [] bs = [] a = path r = math.ceil(len(data)/a) for i in range(a): if len(data) > r: sample = np.random.choice(data, r, replace=False) else: sample = np.random.choice(data, len(data), replace=False) b = [bi[j] for j in list(sample)] bs.append(b) samples.append(sample) for s in sample: data.remove(s) samples = [np.array(s) for s in samples] samples = np.concatenate(samples, axis=0) bs = [np.array(e) for e in bs] bs = np.concatenate(bs, axis=0) return samples, bs请帮我输出每一次的b值并且将导入dataload里面可以用于深度学习
好的,可以按照如下方式修改函数,实现输出每一次的b值并返回可以用于深度学习的数据:
```python
import pickle
import math
import numpy as np
def sample_data(filepath, idx, path):
f = open(filepath, 'rb')
bi = pickle.load(f)
data = np.arange(0, idx)
data = data.tolist()
samples = []
bs = []
a = path
r = math.ceil(len(data) / a)
for i in range(a):
if len(data) > r:
sample = np.random.choice(data, r, replace=False)
else:
sample = np.random.choice(data, len(data), replace=False)
b = [bi[j] for j in list(sample)]
bs.append(b)
samples.append(sample)
for s in sample:
data.remove(s)
print("b值为:", b) # 输出每一次的b值
samples = [np.array(s) for s in samples]
samples = np.concatenate(samples, axis=0)
bs = [np.array(e) for e in bs]
bs = np.concatenate(bs, axis=0)
return samples, bs
# 导入dataload里面可以用于深度学习
filepath = 'data.pkl'
idx = 100
path = 4
samples, bs = sample_data(filepath, idx, path)
```
这样就可以输出每一次的b值,并返回可以用于深度学习的数据了。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)