很基础很重要的一课,虽然很简单,但是防止以后忘了,还是记下来 这个笔记里说的都是import本地的,自己创建的,或者复制粘贴的别人的,总之“不是安装到library”的module or package, 所以标题里有个大写的LOCAL module what’s a module ?It’s just a python file why do we need?Because we wanna re-use code, your own code or someone others’ dir()
site " This module is automatically imported during initialization. The automatic import can be suppressed using the interpreter’s -S option. Importing this module will append site-specific paths to the module search path and add a few builtins. &quo
Python操作文件和目录 读写文件比较简单,有一点特别注意就好了 windows下Python默认打开的文件以gbk解码,而一般我们的文件是utf-8编码的,所以如果文本含有中文,就会出现异常或者乱码.此时手动添加encoding='utf-8'表示以utf-8的方式打开. 当然Python写入时候,也是默认以gbk的编码写入.而文件通常是utf-8格式保存的,所以若不指定写入的编码方式,一写入中文就是乱码了 with open('abc.txt', encoding='utf-8') as