我正在尝试从Gmail帐户中获取可能包含一些大附件(大约30MB)的所有邮件.我只需要名字,而不是整个文件.我找到了一段代码来获取消息和附件的名称,但它会下载文件然后读取其名称:
import imaplib, email
#log in and select the inbox
mail = imaplib.IMAP4_SSL('imap.gmail.com')
mail.login('username', 'password')
mail.select('inbox')
#get uids of all messages
result, data = mail.uid('search', None, 'ALL')
uids = data[0].split()
#read the lastest message
result, data = mail.uid('fetch', uids[-1], '(RFC822)')
m = email.message_from_string(data[0][1])
if m.get_content_maintype() == 'multipart': #multipart messages only
for part in m.walk():
#find the attachment part
if part.get_content_maintype() == 'multipart': continue
if part.get('Content-Disposition') is None: continue
#save the attachment in the program directory
filename = part.get_filename()
fp = …Run Code Online (Sandbox Code Playgroud) 我正在尝试用py2exe创建一个exe.该程序使用Tkinter显示一个类似弹出窗口.问题是,当我像这样运行设置时一切正常:
setup(windows = [{'script': "msg.py"}], zipfile = None)
Run Code Online (Sandbox Code Playgroud)
但是当我尝试制作一个单文件时它失败了:
setup(windows = [{'script': "msg.py"}], zipfile = None, options = {'py2exe': {'bundle_files': 1, 'compressed': True}})
Run Code Online (Sandbox Code Playgroud)
实际上最终的exe运行没有问题,但它没有显示任何窗口.我已经读过在Windows 7上可能存在bundle_files = 1的问题,但我也尝试了bundle_files = 2具有相同的效果.这是我的msg.py脚本:
from win32gui import FindWindow, SetForegroundWindow
from Image import open as iopen
from ImageTk import PhotoImage
from Tkinter import Tk, Label
from threading import Timer
from subprocess import Popen
import os
def Thread(t, fun, arg=None):
if arg<>None: x = Timer(t, fun, arg)
else: x = Timer(t, fun)
x.daemon = True
x.start()
def …Run Code Online (Sandbox Code Playgroud) 有很多提供生成和发送UDP / TCP数据包的应用程序,但是我正在寻找一些在线等效的应用程序。类似于www.wakeonlan.me,但适用于由我定义的有效负载的UDP / TCP数据包(不仅仅是简单的WoL数据包)。
我编写了一些PHP代码来发送简单的UDP数据包,但不幸的是,出于安全原因,该代码已被阻止(我使用了免费的托管服务器)。
有谁知道一些用于简单数据包生成的站点?
此致,
Mopsiok