鱼C论坛

 找回密码
 立即注册
12
返回列表 发新帖
楼主: MSK

[技术交流] Python:每日一题 80(答题领鱼币)

[复制链接]
发表于 2017-8-21 14:01:53 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2017-8-21 14:57:15 | 显示全部楼层
本帖最后由 sunnychou 于 2017-8-21 15:07 编辑


  1. s1 = 'ass hello world'
  2. def rev_string(s1):
  3.     s1 = s1.split()#返回的是字符串列表
  4.     s = []
  5.     for  each in s1:
  6.         s.append(each[::-1])
  7.     return ' '.join(s)
  8. print(rev_string(s1))
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2017-8-21 15:07:58 | 显示全部楼层
  1. s1 = 'ass hello world'
  2. def rev_string(s1):
  3.     s1 = s1.split()#返回的是字符串列表
  4.     s = []
  5.     for  each in s1:
  6.         s.append(each[::-1])
  7.     return ' '.join(s)
  8. print(rev_string(s1))
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2017-8-22 10:47:59 | 显示全部楼层
不是说可以领鱼币吗
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2017-9-13 12:40:00 From FishC Mobile | 显示全部楼层
为什么,我这个没有输出呀?求解答
P70913-123927.jpg
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2017-12-5 09:36:22 | 显示全部楼层
本帖最后由 shigure_takimi 于 2017-12-5 09:38 编辑
  1. def reverse_string(string):
  2.     s = string.split(' ')
  3.     newS = [''.join(list(reversed(word))) for word in s]
  4.     print(' '.join(newS))

  5. # 把s, newS代入print,变成:

  6. def reverse_string2(string):
  7.     print(' '.join([''.join(list(reversed(word))) for word in string.split(' ')]
  8. ))

  9. reverse_string('This is an example!')
  10. reverse_string2('This is an example!')

复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-3-31 23:10:15 | 显示全部楼层
  1. string="This is an example!"

  2. def reverse_string(s):
  3.     lst = s.split(' ')
  4.     for i,v in enumerate(lst):
  5.         lst[i] = v[::-1]
  6.     return lst
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-4-3 21:30:10 | 显示全部楼层
看看
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2018-4-3 21:32:57 | 显示全部楼层
  1. def reverse_string(string):
  2.     lis = string.split()
  3.     lis1 = []
  4.     for i in lis:
  5.         lis2 = []
  6.         for j in i:
  7.             lis2.insert(0,j)
  8.         lis1.append(''.join(lis2))
  9.     return ' '.join(lis1)
  10. string = 'This is an example!'
  11. print(reverse_string(string))
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-6-30 17:00:26 | 显示全部楼层
排序
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-8-1 10:11:19 | 显示全部楼层
1
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-12-9 09:02:05 | 显示全部楼层
学习
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-5-20 18:02

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表