最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

基于python3實(shí)現(xiàn)倒敘字符串

 更新時(shí)間:2020年02月18日 12:54:01   投稿:yaominghui  
這篇文章主要介紹了基于python3實(shí)現(xiàn)倒敘字符串,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

這篇文章主要介紹了基于python3實(shí)現(xiàn)倒敘字符串,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

google測(cè)試工程師的一道題:

設(shè)計(jì)一個(gè)函數(shù),使用任意語言,完成以下功能:

一個(gè)句子,將句子中的單詞全部倒排過來,但單詞的字母順序不變。比如,This is a real world,輸出結(jié)果為

world real a is this.

下面利用python來實(shí)現(xiàn):

句子為:

代碼如下

#!/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()
# 按照空格將文本變?yōu)樽址?
newstring = " ".join(arr)

print(newstring)

結(jié)果:

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

乌兰浩特市| 浦县| 安泽县| 石景山区| 章丘市| 彝良县| 高陵县| 宣威市| 喜德县| 色达县| 长沙市| 石狮市| 鄱阳县| 巩义市| 乌拉特中旗| 康平县| 本溪| 渝中区| 乌兰县| 安乡县| 来安县| 乐东| 安塞县| 潮安县| 新巴尔虎左旗| 平阴县| 基隆市| 和平县| 开鲁县| 泸溪县| 车致| 宁津县| 麦盖提县| 开阳县| 伊宁市| 武夷山市| 个旧市| 陵川县| 鹤壁市| 碌曲县| 铅山县|