Home>
I want to use global functions in Python.
Executefunction task
every 0.1 second, andprint
the count countercnt
in it, andlist
Stores the values obtained by other functions.
Whenprint
is set,cnt
is 0 each time, so it seems that the variable that has been initialized outside the functiontask
has been read. I think.
The following error will also occur.
SyntaxError: name 'cnt' is parameter and global
Applicable source code
#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
Related articles
- i don't understand the exercises using python trigonometric functions
- python 3x - processing to jump to the link destination using chrome driver in python
- parallel processing using python multiprocessingpool and multiprocessingqueue does not work well
- python - combine input with built-in functions
- about external libraries when using multiple versions of python
- python - i want to separate by a specific word using the split function
- python - image recognition using cnn keras multiple inputs
- about batch change of file name using python
- python 3x - i want to get the nth array with an argument using python3 argparse
- python 3x - how to rename a folder created using jupyternotebook
- python - error in image binarization using cv2adaptivethreshold function
- i was given a python 3 assignment as a cram school assignment, but i don't understand "functions and comprehensions, while
- python 3x - about functions used in python for statement
- i want to adjust the execution result using the while statement in python as expected
- python - i want to put the image file path in a variable and open it using that variable
- i don't know the order of processing higher-order functions in python
- python - aggregation processing using pandas
- specifying the range of the graph using python date
- python - about the fibonacci sequence using recursion
- python 3x - what is the best place to declare functions and classes in python?
Trends
Why is the cnt that should be a global variable in the argument! ! And python have been cut off