9 月 152020
 
search = '168'
num_a = '1386-168-0006'
num_b = '1681-222-0006'

print(search + ' is at ' + str(num_a.find(search) + 1) + ' to ' + str(num_a.find(search) + len(search)) + ' of num_a ')
# 168 is at str(num_a.find(search) + 1) to str(num_a.find(search) + len(search)) of num_a
# 168 is at str(5 + 1) to str(5 + 3) of num_a
# 168 is at 6 to 8 of num_a
print(search + ' is at ' + str(num_b.find(search) + 1) + ' to ' + str(num_b.find(search) + len(search)) + ' of num_b ')
PS C:\Users\harveymei> & C:/Users/harveymei/AppData/Local/Programs/Python/Python38/python.exe c:/Users/harveymei/hello.py
168 is at 6 to 8 of num_a 
168 is at 1 to 3 of num_b
PS C:\Users\harveymei>

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)