这是我的代码:
FROM = ''
TO = ''
SMTPSERVER = ''
MYEMAILPASSWORD = ""
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.mime.base import MIMEBase
from email import encoders
def physicallySend(listOfAttachments):
msg = MIMEMultipart('alternative')
msg['Subject'] = "Testing"
msg['From'] = FROM
msg['To'] = TO
textPart = MIMEText("Hello. I should be able to see this body.", 'plain')
msg.attach(textPart)
for attachmentFilename in listOfAttachments:
fp = open(attachmentFilename, 'rb')
file1 = MIMEBase('application','csv')
file1.set_payload(fp.read())
fp.close()
encoders.encode_base64(file1)
file1.add_header('Content-Disposition','attachment;filename=%s' % attachmentFilename)
msg.attach(file1)
server = smtplib.SMTP(SMTPSERVER)
server.ehlo() …Run Code Online (Sandbox Code Playgroud) MediaPlayer从HTTP URL流式传输时,我无法恢复弹性.
如果我开始播放文件,但随后丢弃连接(例如飞行模式),则MediaPlayer#OnErrorListener生成what=1, extra=-17然后不久what=-38, extra=0.
我没有在API中看到这个表示的文档,除了extra是"通常依赖于实现".我正在使用HTC Hero(好吧,它是T-Mobile UK的G2 Touch).
其他人是否获得相同的值,并且可以安全地捕获这些值,因为连接已经消失了吗?
连接重新出现时,如何才能最好地恢复?(保存当前的搜索偏好,并每5秒重试一次?)
我怎么知道设备何时决定开始播放它正在缓冲的内容 - 是否有回调(除了轮询isPlaying())?
此外,我不完全确定onBufferingUpdate提供什么.我正在使用40分钟的播客MP3 (64kbps bitrate)- 缓冲分为1%,2%,3%.当我寻求大约30分钟,它显示75%,然后当我寻求回到开始回到5% - 这个回调的重点是什么,除了显示大约什么是缓存?
最后 - 有什么方法可以管道流式传输到MP3什么?
Android空列表布局
无论我做什么,我都无法显示空标签.在我的标签内,我有:
<LinearLayout
android:id="@+id/thisParticularTab"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="@+id/LastUpdated"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="List last updated: N/A" />
<ListView
android:id="@+id/mySpecialListView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<Button id="@android:id/empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Click to fill the list" /></LinearLayout>
Run Code Online (Sandbox Code Playgroud)
但是,尽管我的ListView为空(没有显示任何项目,并且正在读取的数据库表为空),但不显示该按钮.有任何想法吗?
此外,当它出现时,我能否参考R.id.empty?这是否真的意味着每个活动只能有1个ListView /空?我的理解是'id'用于定义UI定义; 如何为其命名并将其指定为XML中的空视图?(我不想使用setEmptyView())
我的总部设在英国,并且正在努力应对夏令时BST和时区.
这是我的代码:
TIME_OFFSET = 1 # 0 for GMT, 1 for BST
def RFC3339_to_localHHMM(input):
# Take an XML date (2013-04-08T22:35:00Z)
# return e.g. 08/04 23:35
return (datetime.datetime.strptime(input, '%Y-%m-%dT%H:%M:%SZ') +
datetime.timedelta(hours=TIME_OFFSET)).strftime('%d/%m %H:%M')
Run Code Online (Sandbox Code Playgroud)
设置这样的变量感觉非常错误,但我找不到任何优雅的方法来实现上述而没有大量的代码.我错过了什么,是否有办法(例如)读取系统时区?