io - Python loop over files in directory as function argument -


in python scirpt have function func01 takes pdf file argument:

func01("pdf1.pdf") 

this works , gives me expected output.

now want perform func01 on files in directory. tried this:

import glob, os os.chdir("/articles") file in glob.glob("*.pdf"):   myoutput = func01(file) 

... not work: typeerror: 'str' object not callable

searching on so, re-wrote script to:

for file in glob.glob("*.pdf"):   path_  = os.path.realpath(file)   myputput = func01(path_) 

so want use each file loop input function. missing in code?

your error message

typeerror: 'str' object not callable

implies somewhere along line you're doing "some string"(...). in code posted have few function calls.

  • os.chdir("/articles")
  • glob.glob("*.pdf")
  • myoutput = func01(file)

so either os.chdir, glob.glob, or func01 have been overwritten string.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -