1.reload()函數(shù)
Python 2:
reload()函數(shù)封裝在sys模塊中,使用時(shí):
import sys
reload()
Python 3:
reload()不再封裝在sys模塊中,而是importlib,使用方式如下:
import importlib
import yourfile
reload('yourfile')
注意:使用reload()函數(shù)時(shí)需要import你的文件
參考文章:
https://blog.csdn.net/heifan2014/article/details/79266471
2. sys.setdefaultencoding()函數(shù)
Python2:
使用該函數(shù)進(jìn)行utf-8編碼
importsys
reload(sys)
sys.setdefaultencoding("utf-8")
Python3:
若在python3中使用該函數(shù)則會(huì)報(bào)錯(cuò):
AttributeError: module 'sys' has no attribute 'setdefaultencoding
Python3字符串默認(rèn)編碼unicode,因此sys.setdefaultencoding就不存在了
參考文章:
https://blog.csdn.net/fly910905/article/details/74922378
3. raw_input()函數(shù)
Python3將raw_input和input進(jìn)行整合成了input,去除了raw_input()函數(shù)
其接受任意輸入, 將所有輸入默認(rèn)為字符串處理,并返回字符串類型
原文:
https://blog.csdn.net/weixin_40569991/article/details/81053628
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號(hào)聯(lián)系: 360901061
您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對(duì)您有幫助就好】元
