两道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.
因为是刚刚开始学,什么都不懂,所以希望能给个完整的写法
list = ’Sourpuss‘
result = [chr(ord(i)+2) for i in list]
print ''.join(result)
结果是Uqwtrwuu
2.第二个要用到图形库,写起来麻烦啊 参考技术A 给个中文版啊追问
我的题目就是英文版的啊,我对自己的翻译没什么信心啊,
第一题大致是说要编个程序给输入的信息加密,方法是你输入字母,以及数字,然后将你输入的字母按字母表顺序往后推x位,这个x就是你输入的数字,主要是我不太明白怎么解决循环与字母大小写的问题
第二题要求太多,写起来太多,虽然不好意思不过还是自己将就看看吧
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 我的邮箱写的是准确的
使用了StartTTLS扩展登录126的SMTP服务器,但是服务器不支持。应该有另外的方法登录。
用我自己的126帐号实验成功,要加一句:
# 在sendmail前需要先登录、验证发送者身份的~_~
server.login('aaa', 'aaa de mi ma')
fasongfanhui=smtpduixiang.sendmail(youxiang,(youxiang,),youjianxinxi)本回答被提问者采纳
以上是关于两道python语言的程序,帮忙编一下的主要内容,如果未能解决你的问题,请参考以下文章
python 语言发送邮件提示错误.找了资料也没有解决.希望帮帮忙提示一下
如何用python语言编能将字符串中的每个字符的ASCII码加20后输出对应字符的程序?
急~求帮忙写个简单的关于猜投掷骰子的PYTHON程序!!QAQ