用户名:  密码:   
您当前的位置:首页 > 程序设计 >  python > 

Python的一些说明

上次修改时间: 2017-06-16 21:46:21      来源:网络总结      作者:钢铁长陈
上一页      路径:DSD\Learn\python\零基础入门学习Python\      下一页


Win8.1下安装出错,最后安装Python-3.3.3正常
要右击以管理员运行,不然会有2050或2053错误。
注释:
 #单行注释前加井号
 '''
 多行注释前后加三引号
 三引号可是单引,也可是双引
'''


@@重启IDLE, 点Shell->Restart Shell,就重启了IDLE,或按C+F6

1. Traceback (most recent call last):TypeError: 'str' object is not callable 追踪 最,最近的,调用 上一次: 类型错,对象,随时可支取
 原因:使用了保留字作变量名,我是给print赋了值,如pring= 'aa',再用print输出内容时出错,解决方法是重启idle
2. unexpected indent //意想不到的缩进,
 取消每行最前面的缩进,  按Ctrl+[或]可向左或向右缩进
3. TypeError: 'tuple' object is not callable #类型错误,元组对象不可调用
 原因:列表中的每个元组后要加分号
 LANGS=[ #做一个列表
     ("Perl",2), #这里有个分号
     ("Lua",4)]
4.  unexpected character after line continuation character 
原因:用斜框换行是不能出现注释,否则出错,如:
Button(root, text="退出",width=10, command=root.quit)\ #root.quit表退出  //原因是斜后不能有任何内容,包括注释和换行,删掉就正常了
             .grid(row=3,column=1, sticky=E,padx=10,pady=5)
5.  inconsistent use of tabs and spaces in indentation       不一致的Tab和空格缩进
 把Tab换成空格   ,反正就是缩进有问题
 原因:前面的缩进是4个空格,后面的缩进是Tab导致冲突,解决是把Tab替换为空格,大多文本编辑器有这个功能
 注:貌似复制
6. ValueError: need more than 2 values to unpack #值错误,需要超2个值解包
 Traceback (most recent call last):
   File "C:\Users\Administrator\Desktop\851.py", line 71, in <module>
     main()
   File "C:\Users\Administrator\Desktop\851.py", line 50, in main
     ball = Ball(ball_image, position, speed, bg_size)
   File "C:\Users\Administrator\Desktop\851.py", line 12, in __init__
     self.rect.left, self,rect.top = position
 ValueError: need more than 2 values to unpack
 原因找到:self.rect.left, self,rect.top = position  #出现在这句,简直要哭死,点改成了逗号