Tag Archives: share

[Solved] UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xbf in position 7: invalid start byte

The code is as follows:

f = csv.reader(open(csvroot, 'r',encoding='utf-8'))
for i in f:
    print(i)

Solution: view the file encoding format

import chardet

f = open(full_csvroot, 'rb')
data = f.read()
print(chardet.detect(data))

# Outcome:
# {'encoding': 'GB2312', 'confidence': 0.99, 'language': 'Chinese'}

Amend to read:

f = csv.reader(open(csvroot, 'r',encoding='GB2312'))
for i in f:
    print(i)

Perfect operation

Mybatis Error setting non null for parameter #15 with JdbcType null Could not set parameters for

Caused by: org.apache.ibatis.type.TypeException: Error setting non null for parameter #15 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLException: Parameter index out of range (15 > number of parameters, which is 14).
	at org.apache.ibatis.type.BaseTypeHandler.setParameter(BaseTypeHandler.java:71)
	at com.baomidou.mybatisplus.core.MybatisDefaultParameterHandler.setParameters(MybatisDefaultParameterHandler.java:227)
	... 88 more
Caused by: java.sql.SQLException: Parameter index out of range (15 > number of parameters, which is 14).

If a comment SQL fragment exists in the SQL code, the #{} parameter cannot be used in the comment SQL fragment. As follows:

        on t1.dealer_code = t4.dealer_code
        -- left join (
        --     select
        --         ads_code
        --        ,sum(case when car like '%MM%' or model = 'MM' then ss_num else 0 end) as ws_MM_num
        --     from abc_assss_ss
        --     where seq = 1 and count_date between '2021-04-01' and '2021-06-30'
        --     group by
        --         dealer_code
        --     )t2
        -- on t1.asd_code = t2.ads_code
        )
        select
      ~~~
      If you replace the between and with the parameter between #{start_time} and #{end_time}, it will report this error, hope it can solve your problem