I have some issue putting variable into the path [duplicate]
This question already has an answer here:
How do I put a variable inside a String in Python?
7 answers
it 's possible to put a variable into the path in python/linux
for example :
>>>counter = 0;
>>>image = ClImage(file_obj=open('/home/user/image'counter'.jpeg', 'rb'))
I have syntax error when i do that.
python linux variables
marked as duplicate by Daniel Roseman, usr2564301, tripleee
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 12 '18 at 15:57
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
How do I put a variable inside a String in Python?
7 answers
it 's possible to put a variable into the path in python/linux
for example :
>>>counter = 0;
>>>image = ClImage(file_obj=open('/home/user/image'counter'.jpeg', 'rb'))
I have syntax error when i do that.
python linux variables
marked as duplicate by Daniel Roseman, usr2564301, tripleee
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 12 '18 at 15:57
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
The documentation might be helpful here
– DavidG
Nov 12 '18 at 9:59
@Castelo If an answer here has helped you, standard practice on SO is to accept it. Please accept which ever answer helped you the most.
– Adam Mitchell
Nov 12 '18 at 10:59
add a comment |
This question already has an answer here:
How do I put a variable inside a String in Python?
7 answers
it 's possible to put a variable into the path in python/linux
for example :
>>>counter = 0;
>>>image = ClImage(file_obj=open('/home/user/image'counter'.jpeg', 'rb'))
I have syntax error when i do that.
python linux variables
This question already has an answer here:
How do I put a variable inside a String in Python?
7 answers
it 's possible to put a variable into the path in python/linux
for example :
>>>counter = 0;
>>>image = ClImage(file_obj=open('/home/user/image'counter'.jpeg', 'rb'))
I have syntax error when i do that.
This question already has an answer here:
How do I put a variable inside a String in Python?
7 answers
python linux variables
python linux variables
edited Nov 12 '18 at 10:29
betontalpfa
8451023
8451023
asked Nov 12 '18 at 9:56
Castelo Castelo
11
11
marked as duplicate by Daniel Roseman, usr2564301, tripleee
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 12 '18 at 15:57
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Daniel Roseman, usr2564301, tripleee
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 12 '18 at 15:57
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
The documentation might be helpful here
– DavidG
Nov 12 '18 at 9:59
@Castelo If an answer here has helped you, standard practice on SO is to accept it. Please accept which ever answer helped you the most.
– Adam Mitchell
Nov 12 '18 at 10:59
add a comment |
The documentation might be helpful here
– DavidG
Nov 12 '18 at 9:59
@Castelo If an answer here has helped you, standard practice on SO is to accept it. Please accept which ever answer helped you the most.
– Adam Mitchell
Nov 12 '18 at 10:59
The documentation might be helpful here
– DavidG
Nov 12 '18 at 9:59
The documentation might be helpful here
– DavidG
Nov 12 '18 at 9:59
@Castelo If an answer here has helped you, standard practice on SO is to accept it. Please accept which ever answer helped you the most.
– Adam Mitchell
Nov 12 '18 at 10:59
@Castelo If an answer here has helped you, standard practice on SO is to accept it. Please accept which ever answer helped you the most.
– Adam Mitchell
Nov 12 '18 at 10:59
add a comment |
3 Answers
3
active
oldest
votes
You could use an f-string if you’re working in python 3.6+
This is the most efficient method.
counter = 0
filepath = f"/home/user/imagecounter.jpeg"
image = ClImage(file_obj=open(filepath, 'rb'))
Otherwise the second best would be using the .format() function:
counter = 0
filepath = "/home/user/image0.jpeg".format(counter)
image = ClImage(file_obj=open(filepath, 'rb'))
add a comment |
You can use Python's .format() method:
counter = 0
filepath = '/home/user/image0.jpeg'.format(counter)
image = ClImage(file_obj=open(filepath, 'rb'))
add a comment |
You need string concatenation.
>>>counter = 0;
>>>image = ClImage(file_obj=open('/home/user/image' + str(counter) + '.jpeg', 'rb'))
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You could use an f-string if you’re working in python 3.6+
This is the most efficient method.
counter = 0
filepath = f"/home/user/imagecounter.jpeg"
image = ClImage(file_obj=open(filepath, 'rb'))
Otherwise the second best would be using the .format() function:
counter = 0
filepath = "/home/user/image0.jpeg".format(counter)
image = ClImage(file_obj=open(filepath, 'rb'))
add a comment |
You could use an f-string if you’re working in python 3.6+
This is the most efficient method.
counter = 0
filepath = f"/home/user/imagecounter.jpeg"
image = ClImage(file_obj=open(filepath, 'rb'))
Otherwise the second best would be using the .format() function:
counter = 0
filepath = "/home/user/image0.jpeg".format(counter)
image = ClImage(file_obj=open(filepath, 'rb'))
add a comment |
You could use an f-string if you’re working in python 3.6+
This is the most efficient method.
counter = 0
filepath = f"/home/user/imagecounter.jpeg"
image = ClImage(file_obj=open(filepath, 'rb'))
Otherwise the second best would be using the .format() function:
counter = 0
filepath = "/home/user/image0.jpeg".format(counter)
image = ClImage(file_obj=open(filepath, 'rb'))
You could use an f-string if you’re working in python 3.6+
This is the most efficient method.
counter = 0
filepath = f"/home/user/imagecounter.jpeg"
image = ClImage(file_obj=open(filepath, 'rb'))
Otherwise the second best would be using the .format() function:
counter = 0
filepath = "/home/user/image0.jpeg".format(counter)
image = ClImage(file_obj=open(filepath, 'rb'))
edited Nov 12 '18 at 10:49
answered Nov 12 '18 at 10:44
JabaJaba
6,854175294
6,854175294
add a comment |
add a comment |
You can use Python's .format() method:
counter = 0
filepath = '/home/user/image0.jpeg'.format(counter)
image = ClImage(file_obj=open(filepath, 'rb'))
add a comment |
You can use Python's .format() method:
counter = 0
filepath = '/home/user/image0.jpeg'.format(counter)
image = ClImage(file_obj=open(filepath, 'rb'))
add a comment |
You can use Python's .format() method:
counter = 0
filepath = '/home/user/image0.jpeg'.format(counter)
image = ClImage(file_obj=open(filepath, 'rb'))
You can use Python's .format() method:
counter = 0
filepath = '/home/user/image0.jpeg'.format(counter)
image = ClImage(file_obj=open(filepath, 'rb'))
answered Nov 12 '18 at 10:02
Adam MitchellAdam Mitchell
7581627
7581627
add a comment |
add a comment |
You need string concatenation.
>>>counter = 0;
>>>image = ClImage(file_obj=open('/home/user/image' + str(counter) + '.jpeg', 'rb'))
add a comment |
You need string concatenation.
>>>counter = 0;
>>>image = ClImage(file_obj=open('/home/user/image' + str(counter) + '.jpeg', 'rb'))
add a comment |
You need string concatenation.
>>>counter = 0;
>>>image = ClImage(file_obj=open('/home/user/image' + str(counter) + '.jpeg', 'rb'))
You need string concatenation.
>>>counter = 0;
>>>image = ClImage(file_obj=open('/home/user/image' + str(counter) + '.jpeg', 'rb'))
edited Nov 12 '18 at 10:06
Lie Ryan
44.6k968122
44.6k968122
answered Nov 12 '18 at 10:03
betontalpfabetontalpfa
8451023
8451023
add a comment |
add a comment |
The documentation might be helpful here
– DavidG
Nov 12 '18 at 9:59
@Castelo If an answer here has helped you, standard practice on SO is to accept it. Please accept which ever answer helped you the most.
– Adam Mitchell
Nov 12 '18 at 10:59