问题记录一

记录一下学习过程遇到的问题吧,

一、终端中运行py程序,不显示print内容

import os
import time

cmd = "adb shell input tap 1000 275"
i = 1
print('qwer')
while i <= 600:
    print(i, '\t', end='')
    os.system(cmd)
    time.sleep(15)
    i += 1

print('qwer')内容是输出的,while循环里的不是随循环次数而输出,是在程序运行结束后统一输出

思考1:print显示在另一个界面里,当前显示的是os.system的界面?如果是这样,如何验证呢?

二、使用pyinstaller成产exe可执行文件后,运行时一闪而过

代码如下:是用pycharm写的。

import win32api
import win32con
import keyboard
import time

def WithoutShift(*args):  # 不带shift建的输入
	for i in args:
		win32api.keybd_event(i, 0, 0, 0)
		win32api.keybd_event(i, 0, win32con.KEYEVENTF_KEYUP, 0)
		time.sleep(0.05)
	time.sleep(0.05)


def WithShift(*args):
	win32api.keybd_event(16, 0, 0, 0)
	for i in args:
		win32api.keybd_event(i, 0, 0, 0)
		win32api.keybd_event(i, 0, win32con.KEYEVENTF_KEYUP, 0)
		time.sleep(0.05)
	win32api.keybd_event(16, 0, win32con.KEYEVENTF_KEYUP, 0)
	time.sleep(0.05)


keyboard.wait('`')
'''GetPlayer().components.builder:GiveAllRecipes() '''
WithoutShift(65, 13, 192)

WithoutShift(20, 71, 20, 69, 84, 20, 80, 20, 76, 65, 89, 69, 82)
WithShift(57, 48)
WithoutShift(190, 67, 79, 77, 80, 79, 78, 69, 78, 84, 83, 190, 66, 85, 73, 76, 68, 69, 82)
WithShift(186, 71, 65, 82, 57, 48)
WithoutShift(37, 37, 37, 37, 73, 86, 69, 39, 76, 76, 39, 69, 67, 73, 80, 69, 83, 39, 39, 13, 192)

WithoutShift(20, 71, 20, 69, 84, 20, 80, 20, 76, 65, 89, 69, 82)
WithShift(57, 48)
WithoutShift(190, 67, 79, 77, 80, 79, 78, 69, 78, 84, 83, 190, 72, 69, 65, 76, 84, 72)
WithShift(186, 83, 77, 72, 57, 48)
WithoutShift(37, 37, 37, 37, 69, 84, 39, 65, 88, 39, 69, 65, 76, 84, 72, 39, 49, 48, 48, 48, 48, 48, 48, 39, 13, 192)

WithoutShift(20, 71, 20, 69, 84, 20, 80, 20, 76, 65, 89, 69, 82)
WithShift(57, 48)
WithoutShift(190, 67, 79, 77, 80, 79, 78, 69, 78, 84, 83, 190, 72, 85, 78, 71, 69, 82)
WithShift(186, 83, 77, 57, 48)
WithoutShift(37, 37, 37, 69, 84, 39, 65, 88, 39, 49, 48, 48, 48, 39, 13, 192)

WithoutShift(20, 71, 20, 69, 84, 20, 80, 20, 76, 65, 89, 69, 82)
WithShift(57, 48)
WithoutShift(190, 67, 79, 77, 80, 79, 78, 69, 78, 84, 83, 190, 83, 65, 78, 73, 84, 89)
WithShift(186, 83, 77, 57, 48)
WithoutShift(37, 37, 37, 69, 84, 39, 65, 88, 39, 49, 48, 48, 48, 39, 13, 192)

# minimap = TheSim:FindFirstEntityWithTag("minimap")
WithoutShift(77, 73, 78, 73, 77, 65, 80, 32, 187, 32, 20, 84, 20, 72, 69, 20, 83, 20, 73, 77)
WithShift(186, 57, 222, 222, 48)  # :("")
WithoutShift(37, 37, 37, 37, 20, 70, 20, 73, 78, 68, 20, 70, 20, 73, 82, 83, 84, 20, 69, 20, 78, 84, 73, 84, 89,
			 20, 87, 20, 73, 84, 72, 20, 84, 20, 65, 71, 39, 39, 77, 73, 78, 73, 77, 65, 80, 39, 39, 13, 192)

# minimap.MiniMap:ShowArea(0,0,0, 10000)
WithoutShift(77, 73, 78, 73, 77, 65, 80, 190, 20, 77, 20, 73, 78, 73, 20, 77, 20, 65, 80)
WithShift(186, 83, 65, 57, 48)  # :("")
WithoutShift(37, 37, 37, 72, 79, 87, 39, 82, 69, 65, 39, 48, 188, 48, 188, 48, 188, 32, 49, 48, 48, 48, 48, 39, 13)

通过pyinstaller生成exe文件,执行的时候窗口一闪而过,用cmd终端执行,提示以下信息:

Traceback (most recent call last):
  File "test.py", line 1, in <module>
ImportError: DLL load failed while importing win32api: 找不到指定的模块。
[10088] Failed to execute script test

电脑明明装了pywin库的啊,

问题解决了,原来是python3.8的原因:新版的python修改了一些内容,导致不兼容库,所以通过强制导入另一个库,来解决这个bug

所以只要在import win32api 之前,加一句:import pywintypes
https://blog.csdn.net/Eileen_lei/article/details/103749993

三、QTdesigner设计结果与PyCharm运行显示结果不一致

app=QApplication(sys.argv)前加上如下代码
from PyQt5 import QtCore
QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值