小编Sat*_*thy的帖子

Unix sendmail - html嵌入图像不起作用

通过SO.com中的先前帖子,我尝试构建我的脚本,以使用电子邮件正文中的图像内联将电子邮件发送到我的Outlook帐户.但是html内容会在html中显示,而不是显示图像.请帮忙.

这是我的片段

{
echo "TO: XXX@YYY.com"
echo "FROM: TEST_IMAGE@YYY.com>"
echo "SUBJECT: Embed image test"
echo "MIME-Version: 1.0"
echo "Content-Type: multipart/related;boundary="--XYZ""

echo "--XYZ"
echo "Content-Type: text/html; charset=ISO-8859-15"
echo "Content-Transfer-Encoding: 7bit"
echo "<html>"
echo "<head>"
echo "<meta http-equiv="content-type" content="text/html; charset=ISO-8859-15">"
echo "</head>"
echo "<body bgcolor="#ffffff" text="#000000">"
echo "<img src="cid:part1.06090408.01060107" alt="">"
echo "</body>"
echo "</html>"


echo "--XYZ"
echo "Content-Type: image/jpeg;name="sathy.jpg""
echo "Content-Transfer-Encoding: base64"
echo "Content-ID: <part1.06090408.01060107>"
echo "Content-Disposition: inline; filename="sathy.jpg""
echo $(base64 sathy.jpg)
echo "' />"
echo "--XYZ--"
}| /usr/lib/sendmail -t
Run Code Online (Sandbox Code Playgroud)

我收到的电子邮件包含以下内容而非显示图片,

--XYZ …
Run Code Online (Sandbox Code Playgroud)

html unix embed base64

10
推荐指数
1
解决办法
9309
查看次数

Python:XLRD; 比较列长度

我正在使用xlrdxls文件.我的xls文件有两列,我的要求是确保两列的行数相等.我从中了解到help(),我们有一个row_len()查找索引给出的行的长度,但无法找到任何col_len.你能帮忙吗?

这是我的代码

from xlrd import open_workbook
spread_sheet=open_workbook("simple.xls")
sheet1=spread_sheet.sheet_by_index(0)

#validates the no of columns in the Spread sheet
 if sheet1.ncols == 2:
  for sheet1_rows in range(sheet1.nrows):
    for sheet1_cols in range(sheet1.ncols):
        value=sheet1.cell(sheet1_rows,sheet1_cols).value
        source=sheet1.cell(sheet1_rows,0).value
        destination=sheet1.cell(sheet1_rows,1).value
    #ignores the Source and Destination Headers 
    if value not in ('Source','Destination'):
        print "Source is : %s \nDestination is : %s\n" %    (source,destination)
 else:
  print "XLS provided is not valid. Check the no of columns is 2"
Run Code Online (Sandbox Code Playgroud)

除了比较以下之外,还有其他一些选择

>>> print len(sheet1.col_values(0)) …
Run Code Online (Sandbox Code Playgroud)

python xlrd

6
推荐指数
1
解决办法
7292
查看次数

选中整数变量时,Python会忽略字典值

请帮我解决这个简单的问题

x=1
if x["status"] == "Error":
     print "Fine"
elif x == 1:
     print "Good

    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    TypeError: 'int' object has no attribute '__getitem__'
Run Code Online (Sandbox Code Playgroud)

x是函数的返回值,可以是整数或字典.IF如果相反,我不希望我的病情提醒我.

python dictionary if-statement

0
推荐指数
1
解决办法
172
查看次数

标签 统计

python ×2

base64 ×1

dictionary ×1

embed ×1

html ×1

if-statement ×1

unix ×1

xlrd ×1