Python - 在字符串列表中查找数字并返回String + Number

时间:2017-08-20 17:43:45

标签: python-3.x list find alphanumeric

需要这个:

list = ["a_1", "a_2", "a_3", "a_4"]
x = 3
matching = [s for s in list if (x) in s]

我试过了:

list = ["a_1", "a_2", "a_3", "a_4"]
x = "3"
matching = [s for s in list if (x) in s]
matching = 'a_3'

TypeError:' in'需要字符串作为左操作数,而不是int

所以:

itertools.chain()

它有效,但是有更好的方法吗?

1 个答案:

答案 0 :(得分:0)

我真的不知道怎么问,我需要的就是这个:

C:\WINDOWS\system32>tensorboard --inspect --logdir="D:\tmp\fn"
======================================================================
Processing event files... (this can take a few minutes)
======================================================================

Found event files in:
D:\tmp\fn

These tags are in D:\tmp\fn:
audio -
histograms -
images -
scalars
   correct_value_1
   input_1
   loss_1
   output_1
   weight_1
tensor -
======================================================================

Event statistics for D:\tmp\fn:
audio -
graph
   first_step           0
   last_step            0
   max_step             0
   min_step             0
   num_steps            1
   outoforder_steps     []
histograms -
images -
scalars
   first_step           0
   last_step            99
   max_step             99
   min_step             0
   num_steps            100
   outoforder_steps     []
sessionlog:checkpoint -
sessionlog:start -
sessionlog:stop -
tensor -
======================================================================

全部