I want to get the total number of numbers on the list, so I can hear the question!

Asked 2 weeks ago, Updated 2 weeks ago, 1 views

 import numpy as np

import os

import re

seoul_file = open("seoul.txt", "r", encoding = "utf8")

seoul = seoul_file.read().splitlines()

print ("Seoul Data Received"


time12_seoul = []

date12_s = []

date12_s2 = []

def clean_text(inputString): #Remove special characters

  text_rmv = re.sub('[-=+,#/:^[email protected]*\"※~ ·!NNone'|}\(\)\[\]`\'…》\”\“\’·]', '', str(inputString))

  return text_rmv

def list_chunk(lst,n): #Splitlist(when dividing by date)

    return [lst[i:i+n] for i in range(0, len(lst), n)]

def None_del(n,lst):


    for a in n:

        a = list(filter(None, a))
    return lst

for s_time in seoul:     
                  #Only 12 o'clock data in Seoul is contained
    if '12:00' in s_time:


for s_data12 in time12_seoul:

    list_s = s_data12.split(',')
    del list_s[0]
    del list_s[1]
    Value_seoul12 = list_s[0].split(":")
    del Value_seoul12[0]
    Value_seoul12 = clean_text(Value_seoul12)
    if Value_seoul12 == '':
        Value_seoul12 = (Value_seoul12)

    Value2_seoul12 = list_s[1].split(":")
    del Value2_seoul12[0]
    Value2_seoul12 = clean_text(Value2_seoul12)
    if Value2_seoul12 == '':
        Value2_seoul12 = (Value2_seoul12)

s_12 = list_chunk(date12_s, 40)

s2_12 = list_chunk(date12_s2, 40)

date12_s = None_del(s_12, date12_s)

date12_s2 = None_del(s2_12, date12_s2)

I coded in this way and received the data I wanted from the file, but int( Date12_s) is tied up and the sum of the numbers in the list is calculated using sum, and even if you make the int type with map, the sum is not found, so I'm asking you a question.

What I have to do now is to find the sum of date12_s and date12_s2 respectively, but I don't know where to start, so ask me!

python list

2022-09-20 14:24

1 Answers

2022-09-20 14:24

If you have any answers or tips

© 2022 pinfo. All rights reserved.