1 Dictionary Turn characters
Define a dictionary:
Dict = {' name ': ' Python ', ' Age ': 7}
Dictionary-to-character conversions can be cast using str such as:
STR (DICT)
2 Word representable Dictionary:
For example, our data is stored in a dictionary format in a file, but we all read the data type in the file as a character type.
This time, if you want to use a dictionary to manipulate it, it's not going to work. Use the Eval function to convert data to a dictionary type
The output is:
3 Character Turn list
If a string is defined as:
s = ' ad,sad,asdasd,werwer,sdfsdf '
We use the split () method and then reassign the value to a variable #字符串是不可变类型 so we re-assign the value
The new variable is now the list type
Ss=s.split (', ')
Print (Type (ss))
4 List to Characters
If you define a list as:
List1 = [' P ', ' y ', ' t ', ' h ', ' o ', ' n ']
With the Join method, the type of the variable s is the string type.
Conversion between list of character dictionaries in Python