简体   繁体   中英

Passing variables into Python

I would like to replace the strings in the following codeline with variables

myText = re.findall( b'\x03\x00\x00\x02''(.*?)''\xF7\x00\xF0', s)

it should like this then

myText = re.findall( b'\x03\x00\x00\x02''(.*?)' & variable_XY &, s)

How can I do that?

You mean like this?

variable_XY = b'\xF7\x00\xF0'
myText = re.findall(b'\x03\x00\x00\x02(.*?)' + variable_XY, s)

Obviously variable_XY can be set in any way, as long as it is a string.

It's just concatenation.

If you want the contents of variable_XY at the end:

myText = re.findall( b'\x03\x00\x00\x02(.*?)' + variable_XY, s)

If you want the contents of variable_XY at the start:

myText = re.findall( variable_XY + b'\x03\x00\x00\x02(.*?)', s)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM