您好,登錄后才能下訂單哦!
使用python3怎么倒敘字符串?相信很多沒有經驗的人對此束手無策,為此本文總結了問題出現的原因和解決方法,通過這篇文章希望你能解決這個問題。
#!/usr/bin/env python3.4 # -*- coding: utf-8 -*- #某一段文字 data = "You don't need us to tell you that China's Internet space is booming. With the world's largest Internet user population—686 million as of January 2016—and a long way to go to reach Internet penetration levels of developed countries, China's Internet industry is growing in both scale and influence. And as more and more Chinese users come online, Baidu continues to innovate to meet their changing needs and diverse tastes. We aim to serve the needs of our users and customers with products and solutions that prioritize the user experience and reflect our corporate culture – simple and reliable." #按照空格分割 strings = data.split() arr = [] #打印出來 for string in strings: arr.append(string) #將文本倒敘 arr.reverse() # 按照空格將文本變為字符串 newstring = " ".join(arr) print(newstring)
結果:
看完上述內容,你們掌握使用python3怎么倒敘字符串的方法了嗎?如果還想學到更多技能或想了解更多相關內容,歡迎關注億速云行業資訊頻道,感謝各位的閱讀!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。