0

If no input file will show Error TypeError: expected str, bytes or os.PathLike object, not NoneType But I want to show a warning to remind users to input files outside, how to do?

def get_xml_name():
    args = sys.argv
    if len(args) > 1 :
       args = args[1]
       strA = "".join(args)
       return strA



inputfile = open(get_xml_name() , 'r')
TypeError: expected str, bytes or os.PathLike object, not NoneType
CHL
  • 57
  • 7

1 Answers1

0

Instead of

with open(get_xml_name() , 'r') as f:

use

f = open(get_xml_name() , 'r')

then later

f.close()
Erik McKelvey
  • 1,650
  • 1
  • 12
  • 23