python syntax error语法错误

本文深入探讨了Python编程中常见的语法错误,包括类型错误、语法错误、缩进错误等,并解释了如何避免这些错误,同时介绍了Python不同版本的编码方式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.    print(print)   TypeError: 'int' object is not callable

print = 3
print(print)

2.coding : utf-8
               ^
SyntaxError: invalid syntax

3.表达式if ...else语句
    缩进 IndentationError: expected an indented block
                                ^
    IndentationError: unindent does not match any outer indentation level
    SyntaxError: invalid syntax 语法错误
    tab != 4个空格
    
    缩进级别必须保持一致

注释
    单行注释 用#
    多行注释用三个单引号或三个双引号 '''被注释的内容'''

UTF-8 = unicode 的扩展集,可变长的字符编码集   
    Assic -->Gb2312 ->gbk1.0-->gb18030
    Assic -->unicode -->utf-8   /utf-16     
    Python2.x == Assic 默认编码
        #!-*- coding:utf-8 -*-
        #coding:utf-8       
    python3.x == unicode默认编码
      
    unicode 是向下兼容gb2312 , gbk

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值