Python storing a sting + variable + string into a variable -


i have dilemma middle of file name change beginning , end remain same. trying store final result in variable confused on how this.

ips=['10.240.10.5','10.232.10.5','10.200.10.5','10.200.10.6','10.232.10.6','10.240.10.6','10.200.10.7','10.200.10.7']  in ips:         sessionfile = 'sdee_sid_' . i[0] . '.data'         f = open(sessionfile, r)         subscription = f.read() 

i getting errors sessionfile variable...

file "closeallsdeesession.py", line 8     sessionfile = "sdee_sid_" . i[0] . ".data"                                              ^ 

there's no string concatenation operator in python, use +:

'sdee_sid_' + + '.data' 

or printf-like string formatting:

'sdee_sid_%s.data' % 

or new-style string formatting:

'sdee_sid_{}.data'.format(i) 

note i[0] first character of i, might not want.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -