function not returning value. Error “NameError: name 'urlss' is not defined”

前端 未结 1 1323
攒了一身酷
攒了一身酷 2020-12-22 04:14

This is a part of my program. It gives the error NameError: name \'urlss\' is not defined

def testfunc():
  urlss = \"hey\"
  return urlss

prin         


        
相关标签:
1条回答
  • 2020-12-22 05:15

    urlss is a variable local to the scope of testfunc(); it cannot be accessed elsewhere. You might mean

    print testfunc()
    

    which in this case prints urlss, since that's what testfunc() returns.

    0 讨论(0)
提交回复
热议问题