[英]How to automatically add a single quote at the beginning and end of a user input in python
如何在python中的用戶輸入的開頭和結尾處自動添加單引號,以使用戶不必手動進行操作,我的意思是當他們想要輸入時:
this is a text
它會自動變為:
'this is a text'
我有一些帶有特殊字符的文本,它們必須放在單引號內,我很想在輸入這些文本時自動添加單引號。
你的意思是這樣嗎?
userText = raw_input("Enter some text:")
quatedText = "'" + userText + "'"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.