Как я могу удалить кавычки и квадратные скобки из результатов проанализированных результатов, чтобы я мог сохранить их в БД для выполнения аналитики
код питона:
#!/bin/python
import pyparsing as pp
from pyparsing import *
import string
# define the grammar for the log file
integer = Word(nums)
day = Word(alphas)
# example log line
log_display = ("[7]")
# type of record
ut_type = "[" + Word(nums) + "]"
# combine the grammar
log = ut_type
data = log.parseString(log_display)
print(data)
display_type = None
def results(log):
display_type = ut_type.setResultsName("Type of
Record").setParseAction(removeQuotes)
print(display_type)
return display_type
print("outside the function")
print(display_type)
вывод при запуске кода:
$python test.py
['[', '7', ']']
outside the function
None
Я бы хотел получить вывод: -
Type of Record: 7