小编jiz*_*AMA的帖子

在 IDE GoLand 中“下载并安装 32 位 jetbrains 运行时”实际上是做什么的?

我是新手,今天我尝试安装 GoLand。

它有一个名为“下载并安装 32 位 Jetbrains Runtime”的选项。图像: 在此处输入图片说明

我取消选择并安装它,但我也可以hello world成功运行我的第一个。我尝试在 Google 中搜索它,但没有找到。

系统:Windows 10,64 位。(我认为它可能与Java但不确定。)。有人能告诉我它是什么吗?谢谢。

go goland

20
推荐指数
1
解决办法
7484
查看次数

Tkinter 专门跟踪窗口大小调整吗?

我正在编写一个小程序,其目的是在窗口大小更改时运行调整大小方法。为此,我使用了toplevel.bind("<Configure>", self.resize). 虽然这确实适用于调整大小,但该方法会被调用数百次:滚动时、使用某些按钮时,即使窗口大小不会因任何这些操作而改变。如何绑定事件,以便仅在更改窗口大小时调用它?

import tkinter as tk

def resize(event):
    print("widget", event.widget)
    print("height", event.height, "width", event.width)

parent = tk.Toplevel()
canvas = tk.Canvas(parent)
scroll_y = tk.Scrollbar(parent, orient="vertical", command=canvas.yview)
scroll_x = tk.Scrollbar(parent, orient="horizontal", command=canvas.xview)
frame = tk.Frame(canvas)

# put the frame in the canvas
canvas.create_window(0, 0, anchor='nw', window=frame)
# make sure everything is displayed before configuring the scrollregion
canvas.update_idletasks()

canvas.configure(scrollregion=canvas.bbox('all'), 
                yscrollcommand=scroll_y.set,
                xscrollcommand=scroll_x.set)

scroll_y.pack(fill='y', side='right')
scroll_x.pack(fill='x', side='bottom')
canvas.pack(fill='both', expand=True, side='left')

parent.bind("<Configure>", resize)

parent.mainloop()
Run Code Online (Sandbox Code Playgroud)

输出:

widget .!toplevel
height 200 width 200
widget .!toplevel.!scrollbar …
Run Code Online (Sandbox Code Playgroud)

python events tkinter window-resize

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

pywintypes.com_error:(-2147221008,'CoInitialize尚未被调用。',无,无)

当我尝试按原样运行此代码时,出现此错误“IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) pywintypes.com_error: (-2147221008, 'CoInitialize 尚未被调用。', None, None )" ,但是如果我单独运行 stp_tracker ,它工作得很好,如果我单独运行 notify stp ,它工作得很好。我感谢任何人的意见。谢谢

import time
import win32com.client
# import sys
from watchdog.observers import Observer
from watchdog.events import PatternMatchingEventHandler
# import watchdog


class MyHandler(PatternMatchingEventHandler):
    patterns = ["*.stp", "*.step", "*.txt"]

    def process(self, event):
        """
        event.event_type
            'modified' | 'created' | 'moved' | 'deleted'
        event.is_directory
            True | False
        event.src_path
            path/to/observed/file
        """
        # the file will be processed there
        print(event.src_path, event.event_type)

    def on_modified(self, event):
        self.process(event)
        notify_stps()

    def on_created(self, event): …
Run Code Online (Sandbox Code Playgroud)

python events winapi pywin32 watchdog

6
推荐指数
2
解决办法
2万
查看次数

PyDub - [WinError 6] 句柄无效,同时使用 AudioSegment.from_file

我想将音频文件从一种格式转换为另一种格式,所以我使用了 Pydub AudioSegment。

AudioSegment.from_file(input_filename, 'mp4')
Run Code Online (Sandbox Code Playgroud)

python 脚本文件运行良好,但是当我使用 pyinstaller 将其捆绑为可执行文件时,出现以下错误。

我通读了 Github 问题页面并实施了那里建议的解决方案,但这似乎不起作用。我已将 ffmpeg.exe 和 ffprobe.exe 放在我的项目目录中,并使用 AudioSegment.converter 设置路径

   Traceback (most recent call last):
      File "main.py", line 91, in change_format
        converted_audio = AudioSegment.from_file(input_filename, 'mp4')
      File "lib\site-packages\pydub\audio_segment.py", line 685, in from_file
      File "lib\site-packages\pydub\utils.py", line 274, in mediainfo_json
      File "subprocess.py", line 728, in __init__
      File "subprocess.py", line 1025, in _get_handles
    OSError: [WinError 6] The handle is invalid
Run Code Online (Sandbox Code Playgroud)

请提出解决此问题的方法。

python pyinstaller pydub python-3.7

5
推荐指数
0
解决办法
186
查看次数

如何使用 ctypes 中的 IFileOperation

我想使用IFileOperation从 python 代码复制文件 -

  • 它很快(比 python 还快)
  • 你会得到一个很好的对话框
  • 不阻止Python

在 Windows 10 上,Python 3.8 -

import ctypes

ctypes.windll.shell32.IFileOperation
Run Code Online (Sandbox Code Playgroud)

似乎不存在。

我怎样才能使用IFileOperation(不是已弃用的SHFileOperationAPI)ctypes

python winapi ctypes windows-shell python-3.x

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

当我尝试在 Windows 中解密 chrome 密码时,出现此错误 pywintypes.error: (87, 'CryptProtectData', 'Paramètre invalid.')

这是我的所有代码,我尝试用它来解密 Windows 中的 chrome 密码。

\n\n
import os\nimport sqlite3\nimport win32crypt\ndef get_chrome():\n    data_path = os.path.expanduser('~') + r'\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\Login Data'\n    c = sqlite3.connect(data_path)\n    cursor = c.cursor()\n    select_statement = 'SELECT origin_url, username_value, password_value FROM logins'\n    cursor.execute(select_statement)\n    login_data = cursor.fetchall()\n\n    cred = {}\n\n    string = ''\n\n    for url, user_name, pwd in login_data:\n        pwd = win32crypt.CryptUnprotectData(pwd)\n        cred[url] = (user_name, pwd[1].decode('utf8'))\n        string += '\\n[+] URL:%s USERNAME:%s PASSWORD:%s\\n' % (url,user_name,pwd[1].decode('utf8'))\n        print(string)\n\n\nif __name__=='__main__':\n    get_chrome()\n
Run Code Online (Sandbox Code Playgroud)\n\n

它显示的错误是:

\n\n
pywintypes.error: (87, 'CryptProtectData', 'Param\xc3\xa8tre incorrect.') when i'm trying to decrypt chrome …
Run Code Online (Sandbox Code Playgroud)

sqlite google-chrome pywin32 python-3.x

4
推荐指数
1
解决办法
9860
查看次数

Visual Studio 调试错误“错误处理启动:错误:无法附加到主目标

我正在 Codecademy 上开展一个简单的项目,并希望确保我走在正确的轨道上。然而,当我尝试调试代码时,弹出一个简单的 Google 页面,然后读取错误

错误:

我对编码很陌生,所以我不知道从哪里开始。

html debugging visual-studio visual-studio-code

4
推荐指数
3
解决办法
6149
查看次数

使用 pytesseract 从图像生成 PDF

我正在使用以下代码从图像生成 PDF。

PDF=pytesseract.image_to_pdf_or_hocr(test_image,lang='dan',config='',nice=0,extension='pdf')
Run Code Online (Sandbox Code Playgroud)

并且 PDF 变量的类型显示为 BYTES。

我如何发布或生成 PDF?

python ocr python-tesseract

3
推荐指数
2
解决办法
4159
查看次数

__main__.pyinstallerimporterror 无法加载 dynlib/dll“shcore”

我使用pyinstaller打包一个exe文件。

在我的电脑(Win 10)上可以正常运行。

但在别人的电脑(Win 7)上却显示

__main__.pyinstallerimporterror failed to load dynlib/dll "shcore".
Run Code Online (Sandbox Code Playgroud)

关于shcore,我用

import ctypes
PROCESS_PER_MONITOR_DPI_AWARE = 2
ctypes.windll.shcore.SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE)
Run Code Online (Sandbox Code Playgroud)

我应该怎么办?提前致谢。

python winapi pywin32 pyinstaller

3
推荐指数
1
解决办法
1381
查看次数

如何使用 exec() 将值传递给 python 函数中的变量?

一个简单的小问题:

exec("a=3")
print(a)

# This will print 3
Run Code Online (Sandbox Code Playgroud)

如果我使用这个:

def func():
    exec("a=3")
    print(a)

func()

# NameError: name 'a' is not defined.
Run Code Online (Sandbox Code Playgroud)

发生了什么?我如何exec()在函数中为它赋值?

编辑:我发现了一个有同样问题的问题,但仍然没有解决。

你为什么要这么做?

我知道使用exec()是不好的并且不安全。但是最近我尝试解决OP的问题。我遇到了它。

python python-3.x

3
推荐指数
1
解决办法
1638
查看次数

pywin32 ImportError:DLL加载失败:找不到指定的模块

我正在使用python 3.6并尝试import win32com.client使用win32Outlook 发送电子邮件,但不断收到上述内容import error

我已经安装了pywin32pypiwin32并运行了postinstall脚本(确实看到它说“您没有安装 COM 对象的权限。)

我在运行脚本的位置看到了pywintpyes36.dll和。pyhoncom36.dll

我做了一些搜索,似乎找不到我丢失的东西。是因为我无法安装 COM 对象吗?任何帮助将不胜感激,谢谢。

[编辑]

我正在使用 venv,并使用py -m pip install pywin32和安装了两个库py -m install pypiwin32。我确认我在 venv 的“site-packages”文件夹中看到了安装。

我的进口:

import sys
sys.path.append("C:\path\venv\Lib\site-packages")
import tkinter as tk
import getpass
import os.path
import time
import os
import win32com.client as win32
import sqlite3
from datetime import datetime
from functools import partial
Run Code Online (Sandbox Code Playgroud)

我那里有sys.path.append,否则根本找不到该模块。

完整错误消息:

Traceback …
Run Code Online (Sandbox Code Playgroud)

python winapi pywin32

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

Tkinter 文本小部件 - 为什么 INSERT 不能用作文本​​索引?

我有一个令我烦恼的问题。我目前正在使用 Tkinter GUI 构建一个小型应用程序。

在首页上,我想要一些文本或滚动文本小部件中的介绍性文本。我遇到的代码示例使用 INSERT、CURRENT 和 END 等关键字在小部件内进行索引。

我已将以下代码逐字复制粘贴到编辑器中,但它无法识别 INSERT(抛出错误:“NameError:名称'INSERT'未定义”):

import tkinter as tk
from tkinter import scrolledtext

window = tk.Tk()
window.title("test of scrolledtext and INSERT method")
window.geometry('350x200')

txt = scrolledtext.ScrolledText(window,width=40,height=10)
txt.insert(INSERT,'You text goes here')
txt.grid(column=0,row=0)

window.mainloop()
Run Code Online (Sandbox Code Playgroud)

如果我将 [INSERT] 更改为 [1.0],我可以使代码正常工作,但令人非常沮丧的是,我无法使 INSERT 正常工作,因为我在遇到的每个示例代码中都看到了这一点

python tkinter python-3.x tkinter-text

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

Python 中集合、列表和元组的速度测试给出了令人惊讶的结果

set我尝试测试和list之间的速度tuple得到了令人惊讶的结果。

\n\n

在此之前,我知道这比基于此答案set更快list

\n\n

这是我的测试代码:

\n\n
import timeit,time\nfrom sys import getsizeof as Size\n\nList_Test = [range(1000)]\nprint("The Size of List is : {}".format(Size(List_Test)))\nSet_Test = set(range(1000))\nprint("The Size of Set is : {}".format(Size(Set_Test)))\nTuple_Test = tuple(range(1000))\nprint("The Size of Tuple is : {}".format(Size(Tuple_Test)))\n\n\nprint("\\nNow is to test speed\\n")\ntime.sleep(3)\n\ndef Create_List():\n    List = [i for i in range(1000)]\n\ndef Test_List():\n    for i in List_Test:\n        if i == 6:\n            break\n\ndef Create_Set():\n    Set = set(i for i in range(1000))\n\ndef Test_Set():\n    for i …
Run Code Online (Sandbox Code Playgroud)

python list set python-3.x

0
推荐指数
1
解决办法
2296
查看次数