Solution of syntax error: invalid character in identifier when writing Python code
this error is usually caused by illegal spaces. Some advanced editors will directly display red wavy lines to prompt for errors. However, it will not prompt in environments like jupyter notebook, so this error is caused by illegal spaces
Solution:
delete the original space , and then use tab to regenerate the space
Development:
other similar errors using Jupiter notebook, such as: indentation error: undintent does not match any outer indentation level, are also caused by illegal spaces in indentation
generally, if you write code directly, this problem will not appear. The reason for the above error is that you directly copy some code from PDF document, word document or web page to python. So the fundamental way to solve this problem is to write every line of code by yourself, so this problem will not occur