0
입력 된 문자열을 ASCII 값으로 바꾸고 3을 추가 한 다음 모든 문자가 변경된 새 문자열을 출력해야합니다.파이썬 문자열을 ASCII로 다시 입력
내가 목록에서 ASCII 값을 얻을 수있는 지점에 도달했지만 문자열로 다시 변환하는 데 문제가 있습니다.
이것은 내가 지금까지 작성한 코드입니다.
def encrypt (x): #function for encrypting
#y=[ord(c) for c in x] #turns strings into values this works
#y=[3+ ord(c) for c in x] #adds 3 to the values of the letters turned to number this also works
y=str([3+ ord(c) for c in x]) # this does not do what I expected it to do. Neither does char
print(y)
'''def decrypt (x):
y=str([-3 + ord(c) for c in x])
print(y)
'''
x=str(input("Enter something to be encrypted: ")) #gets string to encrypted
encrypt (x) #calls function sends the entered sentence
'''
x=str(input("Enter something to be decrypted: ")) #gets string to decrypted
decrypt (x)
'''
는 내가 편지, 나는 아마 나머지를 알아낼 수 변경으로 문자열을 돌려줘 얻을 수 있다면, 다시 돌려의 두 번째 부분에서 댓글을 달았습니다.
도움을 주셔서 감사합니다.
감사합니다. –