两道python语言的程序,帮忙编一下

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了两道python语言的程序,帮忙编一下相关的知识,希望对你有一定的参考价值。

1、 A Caesar cipher is a simple substitution cipher based on the idea of shifting each letter of the plaintext message a fixed number (called the key) of positions in the alphabet. For example, if the key value is 2, the word “Sourpuss” would be encoded as “Uqwtrwuu.” The original message can be recovered by “reencoding” it using the negative of the key.
Write a program that can encode and decode Caesar ciphers. The input to the program will be a string of plaintext and the value of the key. The output will be an encoded message where each character in the original message is replaced by shifting it key characters in the ASCII character set. For example, if ch is a character in the string and key is the amount to shift, then the character that replaces ch can be calculated as: chr(ord(ch) + key).
2、5-click house. You are to write a program that allows the user to draw a simple house using five mouse-clicks. The first two clicks will be the opposite corners of the rectangular frame of the house. The third click will indicate the center of the top edge of a rectangular door. The door should have a total width that is 1/5 of the width of the house frame. The sides of the door should extend from the corners of the top down to the bottom of the frame. The fourth click will indicate the center of a square window. The window is half as wide as the door. The last click will indicate the peak of the roof. The edges of the roof will extend from the point at the peak to the corners of the top edge of the house frame.
因为是刚刚开始学,什么都不懂,所以希望能给个完整的写法

1.第一个题是凯撒密码,就是明文按字母表顺序右移k个位置得到密文
list = ’Sourpuss‘
result = [chr(ord(i)+2) for i in list]
print ''.join(result)
结果是Uqwtrwuu
2.第二个要用到图形库,写起来麻烦啊
参考技术A 给个中文版啊追问

我的题目就是英文版的啊,我对自己的翻译没什么信心啊,
第一题大致是说要编个程序给输入的信息加密,方法是你输入字母,以及数字,然后将你输入的字母按字母表顺序往后推x位,这个x就是你输入的数字,主要是我不太明白怎么解决循环与字母大小写的问题
第二题要求太多,写起来太多,虽然不好意思不过还是自己将就看看吧

参考技术B 要钱不要分。 参考技术C 第一题大致是说要编个程序给输入的信息加密,哎可惜啊

python 语言发送邮件提示错误.找了资料也没有解决.希望帮帮忙提示一下

python 语言发送邮件提示错误.找了资料也没有解决.希望帮帮忙提示一下
以下是我写的代码没找到哪有问题

from smtplib import SMTP
from poplib import POP3
from time import sleep

smtpfuwuqi='smtp.126.com'
pop3fuwuqi='pop3.126.com'
youxiang='aaa@126.com'

youjiantou=['From:aaa@126.com','to:aaa@126.com','subject:shiyan']
youjianneirong=['shiyan1','shiyan2','shiyan3']
youjianxinxi='\r\n\r\n'.join(['\r\n'.join(youjiantou),'\r\n'.join(youjianneirong)])

smtpduixiang=SMTP(smtpfuwuqi)
fasongfanhui=smtpduixiang.sendmail(youxiang,(youxiang,),youjianxinxi)
smtpduixiang.quit()

for aa in youjianneirong:
print aa

错误提示为:
Traceback (most recent call last):
File "smtp+pop3-shiyan.py", line 15, in <module>
fasongfanhui=smtpduixiang.sendmail('aaa@126.com',('aaa@126.com',),youjianxinxi)
File "/usr/lib/python2.6/smtplib.py", line 698, in sendmail
raise SMTPSenderRefused(code, resp, from_addr)
smtplib.SMTPSenderRefused: (550, '\xd3\xc3\xbb\xa7\xb1\xbb\xcb\xf8\xb6\xa8', 'songkai18@126.com')

我把邮箱改为了 aaa.126.com 我的邮箱写的是准确的

参考技术A 在Fedora11默认安装的Python2.6上出现同样的问题。

使用了StartTTLS扩展登录126的SMTP服务器,但是服务器不支持。应该有另外的方法登录。

用我自己的126帐号实验成功,要加一句:

# 在sendmail前需要先登录、验证发送者身份的~_~
server.login('aaa', 'aaa de mi ma')

fasongfanhui=smtpduixiang.sendmail(youxiang,(youxiang,),youjianxinxi)本回答被提问者采纳

以上是关于两道python语言的程序,帮忙编一下的主要内容,如果未能解决你的问题,请参考以下文章

python 语言发送邮件提示错误.找了资料也没有解决.希望帮帮忙提示一下

我有两道c语言题要做,应该不难,请各位大神帮忙

如何用python语言编能将字符串中的每个字符的ASCII码加20后输出对应字符的程序?

急~求帮忙写个简单的关于猜投掷骰子的PYTHON程序!!QAQ

麻烦哪位高手帮忙解释一下c语言中gcd函数的用法,最好整点简单的例子,谢啦

能不能帮忙注释一下这个程序?选修课的作业,没学过python也不是计算机专业,所以最好详细一点,谢谢了