RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-346486

Alexander Koval's questions

Martin Hope
Alexander Koval
Asked: 2022-08-18 20:55:05 +0000 UTC

将文件拆分为两个文件

  • 0

告诉我,有没有办法让文件分割比我写的更快?

from threading import Thread
from datetime import datetime

def spliter(name):
    now = datetime.now()

    print(f"start spliting at : {now.strftime('%H:%M:%S')}")
    with open(name, "r") as f:
        data = f.readlines()
        sep = int(len(data) / 2)
        first = """"""
        second = """"""

        def dd1():
            nonlocal first
            for i in data[:sep]:
                first += i

        def dd2():
            for i in data[sep:]:
                nonlocal second
                second += i

        t1 = Thread(target=dd1)
        t2 = Thread(target=dd2)
        t1.start()
        t2.start()
        t1.join()
        t2.join()
        file1 = open('first.txt', "w")
        file1.write(first)

        file2 = open('second.txt', "w")
        file2.write(second)
    print(f"end spliting at : {now.strftime('%H:%M:%S')}")


if __name__ == '__main__':
    spliter('Price WA.txt')
python python-3.x
  • 1 个回答
  • 44 Views
Martin Hope
Alexander Koval
Asked: 2020-03-23 19:07:47 +0000 UTC

当您单击kivy设置中的关闭按钮时,如何调用更新应用程序本身的gui的方法

  • 0

这是按钮:

    btn_settings = Button(text="settings", pos_hint={"center_y": 0.97, "center_x": 0.75},
                          size_hint=(0.5, 0.06), on_release=lambda x: App.open_settings(self))

当你点击它时,App类的方法——open_settings被调用,设置被打开。然后我制作了一个单独的更新按钮,但在我看来,当您单击关闭按钮时,有一种方法可以进行这些更新。

在此处输入图像描述

感谢您在我的问题上花费的时间。

python-3.x
  • 1 个回答
  • 10 Views
Martin Hope
Alexander Koval
Asked: 2020-03-10 23:22:56 +0000 UTC

如果有 config.ini 配置文件(如果存在...),如何在启动时更新 Gui

  • 0
from configparser import ConfigParser config = ConfigParser()

config.read('config.ini') print(config.get('main', 'server_inside')) print(config.get('main', 'server_outside')) from kivy.app import App from kivy.lang import Builder from kivy.uix.screenmanager import ScreenManager, Screen from configparser import ConfigParser import os

config = ConfigParser()

Builder.load_string(""" <MenuScreen>:
    canvas.before:
        Color:
            rgba: 255, 255, 255, 0.5
        Rectangle:
            pos: self.pos
            size: self.size


    Button:
        text: 'обновити'
        pos_hint: {"center_y": 0.91, "center_x": 0.75}  
        size_hint: 0.5, 0.06                           
        on_press: root.get_option_for_button()



    Button:
        id: btn1
        text: "1"
        on_release: app.get_option_for_button1()
        pos_hint: {"center_y": 0.15, "center_x": 0.25}
        size_hint: 0.5, 0.06





""")


# Declare both screens class MenuScreen(Screen):

    pass


class SettingsScreen(Screen):

    pass


sm = ScreenManager() sm.add_widget(MenuScreen(name='menu')) sm.add_widget(SettingsScreen(name='settings'))


class TestApp(App):
    config.read("config.ini")

    def build(self):
        return sm



if __name__ == '__main__':
    TestApp().run()

在配置中,按钮 1 的调用方式已经不同,我想从文件中读取它,但我不知道该怎么做......(请告诉我

python
  • 1 个回答
  • 10 Views
Martin Hope
Alexander Koval
Asked: 2020-12-20 19:55:36 +0000 UTC

如何将字节写入文件?

  • 0

使用 msqsql 我可以得到一堆字符串,它们的长度是 30000 个字符

for row in cursor.execute("""select  e.ENTID,ENTTYPE,id.filename,id.type,d.DATA from ATTACHHD id
  join ATTACHDATA d on d.ATTACHKEY=id.ATTACHKEY1
  join ENTITY e on e.ATTACHID=id.ATTACHID
  where id.FILENAME='IMG_0472.jpg'"""):
    print(row.DATA)

一个文件由一堆字节组成:

b'\xff\xd8\xff\xe1E\xfeExif'
b'"\x97s\x01\x96\x1f\xdc>\x95P'
b'o\x10\xb6\xa5\x14\xf7\x02c\x12\xc7'
b'\xdb\xee}\xfd\xa91\x97\xe5\xb6\n'
b'.\xe3\xdb\xda\x80\xb1\x925k\xa8'
b'2+\x02\xc8\x0fn\xe2\x86P\xb6'
b'\x9e\xa34\x05\xcc\x8b\x9dA-\x9e'
b'\x07\xa7\xe5\x8a\xa4\x8d\xeew\xda\xdd'
b'\xc7 U&\x1b\x1a#Y\x90j'
b'\x92i\x0f*\xa0p\xa8|\xcf\x9b'

如何将这束写入文件?

python
  • 2 个回答
  • 10 Views
Martin Hope
Alexander Koval
Asked: 2020-09-04 15:29:30 +0000 UTC

Excel 异常解析器

  • 0
Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\WPython\python-3.7.2.amd64\lib\threading.py", line 917, in _bootstrap_inner
    self.run()
  File "C:\WPython\python-3.7.2.amd64\lib\threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "C:/xlsx/xls_hypertreading.py", line 92, in create_white_list
    self.progress["value"] = 0
  File "C:\WPython\python-3.7.2.amd64\lib\site-packages\openpyxl\worksheet\worksheet.py", line 438, in iter_rows
    max_row = max_row or self.max_row
  File "C:\WPython\python-3.7.2.amd64\lib\site-packages\openpyxl\worksheet\worksheet.py", line 344, in max_row
    rows = set(c[0] for c in self._cells)
  File "C:\WPython\python-3.7.2.amd64\lib\site-packages\openpyxl\worksheet\worksheet.py", line 344, in <genexpr>
    rows = set(c[0] for c in self._cells)
RuntimeError: dictionary changed size during iteration

有一个巨大的xlsx,它以混乱的方式包含很多行。标有颜色的单元格进入一个列表,没有颜色的单元格进入另一个列表,比第一个列表大得多。之后,我查看列表,列表中的一些索引进行数学计算。使用几千行的小 xlsx,一切都可以快速运行,无一例外。但是,一旦您选择大,tkinter 窗口就会冻结几分钟并引发异常。代码示例: 在此处输入图像描述

在此处输入图像描述

python
  • 1 个回答
  • 10 Views
Martin Hope
Alexander Koval
Asked: 2020-08-29 21:26:37 +0000 UTC

获取excel文件中的单元格填充颜色

  • 2

有一个包含一百万行的文件,需要对其进行解析。我实际上是这样做的,但仍有检查此单元格中填充颜色的任务。

# -*- coding: utf-8 -*-
from openpyxl import load_workbook


wb_form = load_workbook("1.xlsx", data_only=True)
sheet_form = wb_form["1"]
wb = sheet_form["B2"].value
f = open("1.txt", "w+")
tmp = 0

for iter, row in enumerate(sheet_form.values):
    if iter == 0:
        continue
    for i in row:
         if i == None:
             continue
         print(i)




f.close()

找不到解决方案。如何在迭代期间检查单元格颜色?

python
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5