解决Python报错:SyntaxError: invalid character ‘,‘ (U+FF0C)
作者:二哈喇子! 时间:2023-01-24 06:12:57
项目场景:
这里简述项目相关背景:
问题描述:
这里描述项目中遇到的问题:
报错:
SyntaxError: invalid character ',' (U+FF0C)
这句话翻译过来大概是:
SyntaxError: invalid(无效的) character(字符) in identifier(标识符)
语法错误:标识符中的存在无效字符。
---------------------------------------------------------------------------------------------------------------------------------
原因分析:
初学新编程语言时会遇到这个问题,一般原因:标识符中存在中文字符,如中文状态下的逗号,括弧等
错误代码:
list = ['Jessica','25',[20,'跳舞'],{80,96},('铁岭',3),{10:'钢琴',‘数学':88}]
细心的朋友应该已经发现了,我这个是符号没改过来,部分符号写成了中文格式
---------------------------------------------------------------------------------------------------------------------------------
解决方案:
仔细检查报错位置的中英文切换符号,问题就会迎刃而解
正确代码:
list = ['Jessica','25',[20,'跳舞'],{80,96},('铁岭',3),{10:'钢琴','数学':88}]
最后这段整体代码也算经典,大家可以试着运行下:
list = ['Jessica','25',[20,'跳舞'],{80,96},('铁岭',3),{10:'钢琴','数学':88}]
print(list[0])
print(list[5])
print(list[-6])
print(list[-1])
print(list[2][0])
print(list[-1][10])
print(list[-1]['数学'])
来源:https://blog.csdn.net/rej177/article/details/122762751
标签:syntaxerror:invalid,python,报错
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
使用coverage统计python web项目代码覆盖率的方法详解
2023-05-23 18:24:35
![](https://img.aspxhome.com/file/2023/9/101559_0s.png)
使用anaconda的pip安装第三方python包的操作步骤
2022-11-20 04:05:22
pyqt5与matplotlib的完美结合实例
2022-01-09 12:23:59
python中的协程深入理解
2021-05-27 21:47:36
![](https://img.aspxhome.com/file/2023/4/111904_0s.png)
如何通过python检查文件是否被占用
2023-03-20 12:25:00
Python+OpenCV图像处理—— 色彩空间转换
2022-02-12 16:28:01
![](https://img.aspxhome.com/file/2023/0/126940_0s.png)
MySQL中order by的执行过程
2024-01-15 00:29:16
![](https://img.aspxhome.com/file/2023/2/126292_0s.webp)
Pytorch创建张量的四种方法
2023-11-20 15:25:36
Python编写nmap扫描工具
2021-08-07 14:53:10
numpy的sum函数的axis和keepdim参数详解
2021-08-02 02:48:46
pygame实现键盘的连续监控
2023-09-26 11:17:10
Python Pyperclip模块安装和使用详解
2023-06-25 13:52:11
asp下用fso和ado.stream写xml文件的方法
2011-04-07 10:55:00
vue实现页面添加水印
2024-05-10 14:19:59
![](https://img.aspxhome.com/file/2023/6/126406_0s.jpg)
Django+Ajax+jQuery实现网页动态更新的实例
2023-02-11 03:23:19
python GUI库图形界面开发之PyQt5线程类QThread详细使用方法
2023-12-03 20:29:40
![](https://img.aspxhome.com/file/2023/1/70221_0s.png)
微信小程序与php 实现微信支付的简单实例
2023-11-14 15:22:07
Python使用Socket(Https)Post登录百度的实现代码
2023-09-19 21:25:34
Python2包含中文报错的解决方法
2021-09-12 20:51:24
![](https://img.aspxhome.com/file/2023/2/102822_0s.png)
CSS双线边框研究
2009-09-03 12:12:00
![](https://img.aspxhome.com/file/UploadPic/20099/3/db_01-71s.jpg)