这是较大项目的一小部分.我只需要获取未读电子邮件并解析其标题.如何修改以下脚本以仅获取未读电子邮件?
conn = imaplib.IMAP4_SSL(imap_server)
conn.login(imap_user, imap_password)
status, messages = conn.select('INBOX')
if status != "OK":
print "Incorrect mail box"
exit()
print messages
Run Code Online (Sandbox Code Playgroud) 如何将变量插入到我用python发送的html电子邮件中?我想要发送的变量是code.以下是我到目前为止的情况.
text = "We Says Thanks!"
html = """\
<html>
<head></head>
<body>
<p>Thank you for being a loyal customer.<br>
Here is your unique code to unlock exclusive content:<br>
<br><br><h1><% print code %></h1><br>
<img src="http://domain.com/footer.jpg">
</p>
</body>
</html>
"""
Run Code Online (Sandbox Code Playgroud) 如何在启动时加载rabbitmq配置以确认创建了代理对象(队列,交换,绑定,用户,虚拟主机,权限和参数).
根据rabbitmq文档,可以通过http://www.rabbitmq.com/management.html#load-definitions完成load_definitions
但我无法弄清楚如何使用它.有人会介意分享一个如何运作的例子吗?我在网上找不到任何例子.
谢谢
我是rtmpdump的新手并且正在努力学习.有关如何使用rtmpdump下载此流的任何想法?
<script type="text/javascript" src="http://castalba.tv/js/jwplayer.js"></script>
<script type="text/javascript">
jwplayer("mediaspace").setup({
'flashplayer': "http://static.castalba.tv/player.swf",
'width': '650',
'height': '400',
'allowfullscreen':'true',
'allowscriptaccess':'always',
'wmode':'opaque',
'controlbar':'over',
'dock':'true',
'dock.position':'left',
'mute':'false',
'stretching':'uniform',
'autostart': 'true',
'rtmp.subscribe': 'true',
'file': 'ChelTV_Ch01_1000k@26291',
'streamer': 'rtmpe://cp96798.live.edgefcs.net/live/',
'rtmp.tunneling': 'false',
'logo.file':'http://castalba.tv/images/playerlogo.png',
'logo.hide':'false',
'logo.position':'top-right',
'logo.link':'http://castalba.tv',
'abouttext':'CastAlba.TV - Stream Live Video',
'aboutlink':'http://castalba.tv',
'skin':'http://static.castalba.tv/bluez.zip'
});
</script>
Run Code Online (Sandbox Code Playgroud) 我可以打印密钥:
$ jq -r '.indices | keys[]'
plan
resource
user
Run Code Online (Sandbox Code Playgroud)
我可以打印子值:
$ jq '.indices[] | .primaries.docs.count'
14208
1427143
104475
Run Code Online (Sandbox Code Playgroud)
如何打印键和子值?
plan: 14208
resource: 1427143
user: 104475
Run Code Online (Sandbox Code Playgroud) import re
from sqlalchemy import *
db = create_engine('sqlite:///code.db')
db.echo = True
metadata = MetaData(db)
halo4 = Table('emblem_codes', metadata, autoload=True)
#########################
## Get One Unused Code ##
#########################
s = select([halo4.c.code, halo4.c.status=='None'])
result = s.execute()
for row in result:
print row
Run Code Online (Sandbox Code Playgroud)
我的代码返回所有80999结果.我只想要一个.什么是最好的方法呢?
这是code.db的示例:
(u'JRQRY-MYHW3-D67GR-7YWFF-CRJ31', None)
(u'9D7DR-4WFDY-VG49F-3DYCG-7DYT5', None)
(u'QR9WT-P3CTM-PW4WW-34JJ4-RFKV7', None)
(u'7FMXQ-H97TC-FFYC6-XHXFV-Y7KR2', None)
(u'VKHXW-29WC4-4PF4Y-2QMJ4-4W2H4', None)
Run Code Online (Sandbox Code Playgroud) 1) 如何升级 postgres 扩展?
2)你如何安装特定的扩展版本?
在生产中,hstore 的版本已过时。
=> select * from pg_available_extensions where name ='hstore';
name | default_version | installed_version | comment
--------+-----------------+-------------------+--------------------------------------------------
hstore | 1.3 | 1.1 | data type for storing sets of (key, value) pairs
Run Code Online (Sandbox Code Playgroud)
所有其他环境 hstore 已经是 1.3,所以我没有办法测试是否create extension hstore;是我所需要的。
我想先测试升级并通过 Docker 运行 Postgres 9.4.4
docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres:9.4.4
docker run -it --rm --link some-postgres:postgres postgres:9.4.4 psql -h postgres -U postgres
Run Code Online (Sandbox Code Playgroud)
但是 hstore 1.3 是默认版本
name | default_version | installed_version …Run Code Online (Sandbox Code Playgroud) 我有一个看起来像这样的csv文件:
artist,year,id,video_name,new_video_id,file_root_name,video_type
,,,,,,
Clay Aiken,1,clay_aiken,Sorry Seems To Be...,sorry-seems-to-be,02_sc_ca_sorry,FLV
Clay Aiken,1,clay_aiken,Everything I Do (I Do It For You),everything-i-do-i-do-it-for-you,03_sc_ca_everything,FLV
Clay Aiken,1,clay_aiken,A Thousand Days,a-thousand-days,04_sc_ca_thousandda,FLV
Clay Aiken,1,clay_aiken,Here You Come Again,here-you-come-again,05_sc_ca_hereyoucom,FLV
Clay Aiken,1,clay_aiken,Interview,interview,06_sc_ca_intv,FLV
Run Code Online (Sandbox Code Playgroud)
上面的每一行都会生成一个单独的xml文件,如下所示(准确地说是5个):
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE smil PUBLIC "-//W3C//DTD SMIL 2.0//EN" "http://www.w3.org/2001/SMIL20/SMIL20.dtd">
<smil xmlns="http://www.w3.org/2001/SMIL20/Language">
<head>
<meta base="rtmp://cp23636.edgefcs.net/ondemand" />
</head>
<body>
<switch>
<video src="mp4:soundcheck/%year/%id/%file_root_name_256.mp4" system-bitrate="336000"/>
<video src="mp4:soundcheck/%year/%id/%file_root_name_512.mp4" system-bitrate="592000"/>
<video src="mp4:soundcheck/%year/%id/%file_root_name_768.mp4" system-bitrate="848000"/>
<video src="mp4:soundcheck/%year/%id/%file_root_name_1128.mp4" system-bitrate="1208000"/>
</switch>
</body>
</smil>
Run Code Online (Sandbox Code Playgroud)
命名为%new_video_id.smil
我想出了如何解析csv文件:
import csv
import sys
f = open(sys.argv[1], 'rU')
reader = csv.reader(f)
for row in reader: …Run Code Online (Sandbox Code Playgroud) 我正在尝试过滤此代码之间的数据 <cookie>与</cookie>和之间的数据account-id="和"(尾随报价)
<?xml version="1.0" encoding="utf-8"?>
<results>
<status code="ok"/>
<common locale="en" time-zone-id="85">
<cookie>na3breezfxm5hk6co2kfzuxq</cookie>
<date>2012-11-11T16:26:52.713+00:00</date>
<host>http://meet97263421.adobeconnect.com</host>
<local-host>pacna3app09</local-host>
<admin-host>na3cps.adobeconnect.com</admin-host>
<url>/api/xml?action=common-info</url>
<version>8.2.2.0</version>
<tos-version>7.5</tos-version>
<product-notification>true</product-notification>
<account account-id="1013353222"/>
<user-agent>curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5</user-agent>
</common>
</results>
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激.
编辑
这是我运行的curl命令,用于返回上面的xml.
curl -s http://meet97263421.adobeconnect.com/api/xml?action=common-info
Run Code Online (Sandbox Code Playgroud) 我花了最后两个小时试图解决这个问题.请帮助我在过去两个小时内尝试使用Google.没运气.我究竟做错了什么?
codes.txt的内容:
TKF6J-KXP6V-F499V-Q9XPC-7J6TZ;J9YCV-D4TH6-WWWWV-F2RM7-F63XZ;GXKCC-QDT34-3JRY4-TWKHX-R763Z;
Run Code Online (Sandbox Code Playgroud)
myscript.py
import re
from sqlalchemy import *
string = open("codes.txt").readlines()
for item in string:
set = [item.split(";")]
print "success"
Run Code Online (Sandbox Code Playgroud)
为什么它只打印一次"成功"?我希望它能为codes.txt中的项目数量打印成功.
我没有看到第三个论点.当我运行此命令时:
used_emails = [row.email for row
in db.execute(halo4.select([halo4.c.email],[halo4.c.email!='']))]
Run Code Online (Sandbox Code Playgroud)
它说:
TypeError:select()最多需要2个参数(给定3个)
第三个论点在哪里?
我只想要以.jpg或.pdf结尾的文件名.如何限制文件名搜索?
import os
from subprocess import call
for dirname, dirnames, filenames in os.walk('.'):
for filename in filenames:
jpg = os.path.join(dirname, filename)
call(["./curl_recognize.sh", jpg, jpg+".txt", "-f txt"])
Run Code Online (Sandbox Code Playgroud) 使用IMAPClient如何查看邮件正文和发件人电子邮件地址?
server = IMAPClient(imap_server, use_uid=True, ssl=ssl)
server.login(imap_user, imap_password)
print 'login successful'
select_info = server.select_folder('INBOX')
print '%d messages in INBOX' % select_info['EXISTS']
messages = server.search(['NOT DELETED'])
print "%d messages that aren't deleted" % len(messages)
print
print "Messages:"
response = server.fetch(messages, ['FLAGS', 'RFC822.SIZE'])
for msgid, data in response.iteritems():
print ' ID %d: %d bytes, flags=%s' % (msgid,
data['RFC822.SIZE'],
data['FLAGS'])
Run Code Online (Sandbox Code Playgroud) python ×8
imaplib ×2
sqlalchemy ×2
xml ×2
csv ×1
curl ×1
email ×1
html-email ×1
imapclient ×1
jq ×1
os.walk ×1
postgresql ×1
rabbitmq ×1
rtmp ×1
smtplib ×1
xml-parsing ×1