I want to use global functions in Python.
function taskevery 0.1 second, and
cntin it, and
listStores the values obtained by other functions.
cntis 0 each time, so it seems that the variable that has been initialized outside the function
taskhas been read. I think.
The following error will also occur.
Applicable source code
SyntaxError: name 'cnt' is parameter and global
#Initialize cnt = 0 list =  def task (cnt, list): global cnt global list cnt + = 1 print (cnt) signal.signal (signal.SIGALRM, task) signal.setitimer (signal.ITIMER_REAL, 0.1, 0.1)
Where is the cause?
Answer # 1
def task (cnt, list):
Why is the cnt that should be a global variable in the argument! ! And python have been cut off
- python - combine input with built-in functions
- python - i want to do template matching at once using a for statement
- python - i was able to upload with cloud functions of gcp (google cloud platform), but an error occurred in the test
- i want to keep spreadsheet functions in python gspread
- python - sum of matrices using a list
- python - i can't double derivative and assign functions in sympy
- python - enlarge the image using a for statement in opencv
- python - i can't understand the argument of lambda when using sorted please help me
- python - i don't know how to get pk when using formview in django
- python - i want to change the save destination for each loop using chromedriver
- can multiple file io by built-in function open using multithreading in python be expected to be faster?
- i want to store data using a for statement using a table in html in python, but it is not displayed well
- i want to calculate multiple centroids using python and opencv
- i want to display an image using opencv from python
- i want to read an image file with python using pillow
- python - i want to define a function using a csv file
- i want to combine split images using cv2 (python)
- file reading and calculation using python
- python - how to handle functions, how to branch conditionals, how to place exceptions
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- python - you may need to restart the kernel to use updated packages error
- python 3x - typeerror: 'method' object is not subscriptable
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- xcode - pod install [!] no `podfile 'found in the project directory
- vuejs - [vuetify] unable to locate target [data-app] i want to unit test to avoid warning
- android studio - unresolved reference comes out in kotlin