Py学习  »  Python

for循环中的Python打印格式

Mohammad Hassani • 2 年前 • 495 次点击  
*if menuInput == '1':
     print("")
     encryptString = input("Please enter string to encrypt:")
     print("")
     offSetValue = int(input("Please enter offset value (1-94):"))
     print("")
 
     for character in encryptString:
         x = ord(character)
         y = x + offSetValue
         z = chr(y)      
         print("Encrypted string:") 
         print(z)*

我希望已加密的字符串以以下格式输出:

加密字符串:

abcde 

但它是以这种形式出现的:

Encrypted string: 
a
Encrypted string: 
b
Encrypted string: 
c
Encrypted string: 
d

我试过使用end和sep,但都没有用。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/132756
 
495 次点击  
文章 [ 3 ]  |  最新文章 2 年前