程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python text layout tool

編輯:Python

  Procedural requirements

  Program code

article = input(" Please enter the content you need to typeset :")
choice = int(input(" Please select the function you want to use (1. Delete the blank space 2. English punctuation replacement 3. Capitalize English words ):"))
if choice == 1:
article = article.replace(" ", "")
elif choice == 2:
choice2 = int(input(" Please select the function you want to use (1. Replace all English punctuation with Chinese punctuation 2. Replace all Chinese punctuation with English punctuation ):"))
if choice2 == 1:
article = article.replace(",", ",")
article = article.replace(".", ".")
article = article.replace(":", ":")
article = article.replace(";", ";")
article = article.replace("!", "!")
article = article.replace("?", "?")
elif choice2 == 2:
article = article.replace(",", ",")
article = article.replace(".", ".")
article = article.replace(":", ":")
article = article.replace(";", ";")
article = article.replace("!", "!")
article = article.replace("?", "?")
else:
print(" Input error, please input again !!!")
elif choice == 3:
choice3 = int(input(" Please select the function you want to use (1. title case , The rest of the letters are lowercase 2. The full text is capitalized 3. Full text words are capitalized ):"))
if choice3 == 1:
article = article.capitalize()
elif choice3 == 2:
article = article.title()
elif choice3 == 3:
article = article.upper()
else:
print(" Input error, please input again !!!")
else:
print(" Input error, please input again !!!")
print(" Content after typesetting :", article)

Running results : 


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved