TA的每日心情 | 奋斗 2019-10-13 07:34 |
---|
签到天数: 209 天 [LV.7]常住居民III
|
发表于 2020-7-28 09:16:14
|
显示全部楼层
本帖最后由 VimVim 于 2020-7-28 09:32 编辑 , U4 k0 \; g9 O( r- ]8 n
4 ~7 l5 B! w4 Zpython: % u/ @; P3 S. t0 Y& A% }$ N- j. w9 H: }
8 }- F0 Z4 U& j
import random
5 F9 I1 u- c7 C* r2 cYourEnglishSentence=input() M [, Q C9 Q2 U/ Q
WordsList=YourEnglishSentence.split()4 b* z6 c" Y* B# X( J4 `( Y+ k# w
random.shuffle(WordsList)
5 d$ `* p! c0 ?$ y% Z, x5 }print(WordsList). [# ~; Z5 l( Q) }# W
/ m: D1 F+ x9 D" I' p
, r1 Y9 P$ Z- w( B例如:7 @4 }0 y0 I5 f! p4 }
. V% Q: _3 Y# _3 `7 c>>> import random, ~' l( e. @- X. R2 I
>>> YourEnglishSentence="This is a red apple!"; q7 }1 k9 b8 u8 P
>>> WordsList=YourEnglishSentence.split()5 Q: t4 o9 V4 W: ?
>>> random.shuffle(WordsList)
1 p$ X/ K' S5 o9 |* E, [/ \ p, g>>> print(WordsList)
, w# N5 U1 G% M3 m9 g, I['a', 'is', 'red', 'This', 'apple!']
, f) ]2 e3 t! P>>> random.shuffle(WordsList)5 b& C5 {9 ~; T; y$ H
>>> print(WordsList)% Q. B" I1 F- y! ^: P
['This', 'apple!', 'a', 'red', 'is']
/ J! G$ z$ V6 X3 i>>>
- j6 \ Z4 q( t3 O( E! ~: w; Q: m2 z- e
|
|