python 3教程:基於python3實現倒敘字符串

這篇文章主要介紹了基於python3實現倒敘字符串,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下

google測試工程師的一道題:
設計一個函數,使用任意語言,完成以下功能:
一個句子,將句子中的單詞全部倒排過來,但單詞的字母順序不變。比如,This is a real world,輸出結果爲
world real a is this.
下面利用python來實現:

句子爲:
在這裏插入圖片描述
代碼如下

#!/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."
 
#按照空格分割

結果:在這裏插入圖片描述
以上就是本文的全部內容,希望對大家的學習有所幫助
推薦我們的python學習基地,看前輩們是如何學習的!從基礎的python腳本、爬蟲、django、數據挖掘等編程技術,還有整理零基礎到項目實戰的資料,送給每一位愛學習python的小夥伴!每天都有老前輩定時講解Python技術,分享一些學習的方法和需要留意的小細節,點擊加入我們的 python學習者聚集地

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章