问题:说我有一个清单 a = ['abd', ' the dog', '4:45 AM', '1234 total', 'etc...','6:31 PM', '2:36']
我该如何去删除元素如4:45 AM和6:31 PM和"2:36"?即,如何删除表单元素number:number|number和末尾AM/PM 元素?
说实话,我没有多尝试,因为我不确定到底哪里开始,除了以下内容:
[x for x in a if x != something]
Run Code Online (Sandbox Code Playgroud) 在 1.0.40,我的 MacBook 需要在 1.0.39。谁能告诉我怎么降级。谢谢!
原因是我需要连接到服务器并发送托管我的自动化设备的 adb 命令。但是,服务器是@ 1.0.39 并且我没有(当前)方法将其升级到 1.0.40 ......如果没有它们在同一版本上,我无法做我需要做的......
list = ['the dog ran', 'tomorrow is Wednesday', 'hello sir']
Run Code Online (Sandbox Code Playgroud)
我想搜索包含单词 Sunday 的元素,并在开头用换行符替换该元素。所以:
new_list = ['the dog ran', '/ntomorrow is Wednesday', 'hello sir']
Run Code Online (Sandbox Code Playgroud)
任何帮助都会很棒。我尝试过的一切都没有奏效。谢谢。
所以说我有:
a = ['the dog', 'cat', 'the frog went', '3452', 'empty', 'animal']
b = [0, 2, 4]
Run Code Online (Sandbox Code Playgroud)
我怎么能回来:
c = ['the dog', 'the frog went', 'empty'] ?
Run Code Online (Sandbox Code Playgroud)
即如何从a中返回第n个元素,其中n包含在单独的列表中?