在我的任务中,我需要做的是从时间(下午2:34)减去一些小时和分钟,如(0:20,1:10 ...任何值),在输出端我需要显示时间后减法.时间和小时:分钟值是硬编码的
例如:
my_time = 1:05 AM
持续时间= 0:50
所以输出应该是下午12:15
输出应精确且采用AM/PM格式,适用于所有值[0:00 <持续时间> 6:00]
并且不关心只需几秒钟和几分钟所需的部件
我需要从图像中删除所有空白,但我不知道该怎么做。我想从中删除空格
我的代码
from PIL import Image, ImageChops
import numpy
def trim(im):
bg = Image.new(im.mode, im.size, im.getpixel((0, 0)))
diff = ImageChops.difference(im, bg)
diff = ImageChops.add(diff, diff, 2.0, -100)
box = diff.getbbox()
if box:
im.crop(box).save("trim_pil.png")
im = Image.open("/home/einfochips/Documents/imagecomparsion/kroger_image_comparison/SnapshotImages/screenshot_Hide.png")
im = trim(im)
Run Code Online (Sandbox Code Playgroud)
但此代码仅从边框中删除空格,我还需要从中间删除空格。如果可能,请提供帮助,如果我将所有五个图像都放在不同的 PNG 文件中,那就太好了。
python opencv imagemagick image-processing python-imaging-library
在我的任务中,我想只获取时间并存储在变量中,在我的字符串中,时间可能超过1次,可能是"AM"或"PM"
我只想从我的字符串中存储这个值."4:19:27"和"7:00:05"时间的发生可能超过两次.
str = """ 16908310=android.widget.TextView@405ed820=Troubles | 2131034163=android.widget.TextView@405eec00=Some situations can be acknowledged using the 'OK' button, if present. A green check-mark after the description indicates that the situation has been acknowledged. Some situations have further detail available by pressing on the text or icon of the trouble message. | 2131034160=android.widget.TextView@407e5380=Zone Perl Thermostatyfu Communication Failure | 2131034161=android.widget.RadioButton@4081b4f8=OK | 2131034162=android.widget.TextView@4082ac98=Sep 12, 2017 4:19:27 AM | 2131034160=android.widget.TextView@40831690=Zone Door Tampered | 2131034161=android.widget.RadioButton@4085bb78=OK | 2131034162=android.widget.TextView@407520c8=Sep 12, 2017 7:00:05 PM | VIEW : -1=android.widget.LinearLayout@405ec8c0 | -1=android.widget.FrameLayout@405ed278 …Run Code Online (Sandbox Code Playgroud)