Python常见问题集锦

1、illegal multibyte sequence报错

在函数的参数内加上文件的对应编码方式,例:

        config = configparser.ConfigParser()
        config.read('test.ini',encoding='UTF-8')

2、ModuleNotFoundError: No module named 'ConfigParser'报错

Python3中应写为    import   configparser

Python2中应写为    import   ConfigParser

3、安装工具包指令

在DOS窗口下输入命令    pip install 工具包名  

安装完成后要重启Python  IDLE才能import成功

4、数组、字符串、元组的相互转化

list()方法      字符串或元组  ----》   数组

tuple()方法  字符串或数组 ------》   元组

"".join()方法 数组或元组    -------》  字符串

例:

>>> str_ = '123456'
>>> list(str_)
['1', '2', '3', '4', '5', '6']
>>> tuple(str_)
('1', '2', '3', '4', '5', '6')
>>> list(tuple(str_))
['1', '2', '3', '4', '5', '6']
>>> "".join(tuple(str_))
'123456'

5、Python文件生成.exe

https://blog.csdn.net/Key_book/article/details/80266733

6、list中查找字符串是否存在

https://blog.csdn.net/lachesis999/article/details/53185299

7、判断变量类型方法

https://www.cnblogs.com/jessicaxu/p/7727264.html

8、Python2.7     No module named 'PIL' 解决方法

https://www.cnblogs.com/cnxkey/articles/8574100.html

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值