I want to concatenate to get a big string:
big_str = ''
def create_big_str():
with open('big.txt', 'r') as f:
for line in f:
if not line:
continue
big_str = big_str + ' ' + line
then in other places, i want to use the 'big_str' variable. But it reports the error:
UnboundLocalError: local variable
at the line:
big_str = big_str + ' ' + line
Add the 'global' doesn't help either.