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

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