Home > other >  The python string list
The python string list

Time:10-13

A="[[sd, HTTF, g], [sd, HTTF, g]]"
How to this list

CodePudding user response:

What was the outcome of the transformation?

Changing all simple string list is easy to list (a)

CodePudding user response:

feel you didn't describe clearly, please post a problem or the topic all of text,

CodePudding user response:

The letter is inside the string?

CodePudding user response:

The import re

S="[[sd, HTTF, g], [sd, HTTF, g]]"


S=eval (re. Sub (" (? P \ w +) ", lambda x: repr (x.g roup (" value ")), s))

Print (s [0] [0])

CodePudding user response:

A="[[sd, HTTF, g], [sd, HTTF, g]]"
This will convert to
A=[[' sd ', 'HTTF', 'g'], [' sd ', 'HTTF', 'g']]

CodePudding user response:

refer to the second floor brother huang Python training response:
feeling you have no description is clear, the text of the problem or the topic all please be posted,


A="[[sd, HTTF, g], [sd, HTTF, g]]"
This will convert to
A=[[' sd ', 'HTTF', 'g'], [' sd ', 'HTTF', 'g']]

CodePudding user response:

refer to 6th floor yepp13 response:
Quote: refer to the second floor brother huang Python training response:

feel you didn't describe clearly, please post a problem or the topic all of text,


A="[[sd, HTTF, g], [sd, HTTF, g]]"
This will convert to
A=[[' sd ', 'HTTF', 'g'], [' sd ', 'HTTF', 'g']]

Look on the fourth floor, helped him land!!!!!!!!!!

CodePudding user response:

reference 4 floor JMZL response:
import re

S="[[sd, HTTF, g], [sd, HTTF, g]]"


S=eval (re. Sub (" (? P \ w +) ", lambda x: repr (x.g roup (" value ")), s))

Print (s [0] [0])

The great god, can you explain it, the result is out, but not very understand this process

CodePudding user response:

Ask questions to clarify, you right, also can be so

CodePudding user response:

refer to the eighth floor yepp13 response:
Quote: refer to 4th floor JMZL response:

The import re

S="[[sd, HTTF, g], [sd, HTTF, g]]"


S=eval (re. Sub (" (? P \ w +) ", lambda x: repr (x.g roup (" value ")), s))

Print (s [0] [0])

A great god, can you explain it, the result is out, but not very understand this process

Where is not ideal? What other need?

CodePudding user response:

The import re

A='[[sd, HTTF, g], [sd, HTTF, g]]'
List=[]

Ma=re. The.findall (r '[(\ w |,)] + \ w', a)
For x in ma:
List. Append (x.s plit (', '))

print(list)

CodePudding user response:

[and] delete all of the string, and then split (', ') cut out, the rest is independent of the string, it becomes easy

CodePudding user response:

Eval (" [[sd, HTTF, g], [sd, HTTF, g]] ", the replace (", ", "', '"). The replace (" [[[['", "). The replace ("]] ", "']] "))
  • Related