python常用模块初始
2017-03-14 16:58
369 查看
python常用模块初始
1.getpass(密文输入)
1.getpass(密文输入)
import getpass #导入getpass模块,用于密文输入 name = input("input your name:") passwd = getpass.getpass("input your passwd:") #密文输入 print (name,passwd)2.OS模块
#!/bin/bash/env python #_*_ coding:utf-8 _*_ import os 例1 #直接执行linux命令“df -lh” os.system("df -lh") 例2 #创建abc目录 os.mkdir("abc") 例3 #打印命令执行结果是否成功,成功返回None; a = os.system("df -lh") print(a) 例4 #将linux执行查询到的内容复制给变量 aa = os.popen("df -lh").read() #先用popen读取df-lh 获取的内容读到内存,再用read读出来赋值给aa ; print(aa)3.tab模块
查找python默认全局环境变量位置: import sys #导入sys模块 print (sys.path) #打印python的所有目录,python放模块的目录是/usr/lib/python2.7/dist-packages #把文件上传到该目录下,名字tab.py import tab #os.就可以tab补全了;注意不能加.py #tab模块要自己写; #每一个脚本都可以是一个模块; 具体TAB模块内容: #!/bin/bash/env python #_*_ coding:utf-8 _*_ # python startup file import sys import readline import rlcompleter import atexit import os # tab completion readline.parse_and_bind('tab: complete') # history file histfile = os.path.join(os.environ['HOME'], '.pythonhistory') try: readline.read_history_file(histfile) except IOError: pass atexit.register(readline.write_history_file, histfile) del os, histfile, readline, rlcompleter4.sys模块
python查找全局环境变量路径 方法: import sys #导入sys模块 print (sys.path)
相关文章推荐
- python整理七——数字的一些常用模块
- [转]常用的python模块及安装方法
- [转]常用的python模块及安装方法
- Python里的OS模块常用函数说明
- Python常用模块
- [转载] Python 常用模块整理
- Python 常用模块
- [转载]Python学习笔记三(常用模块)
- python基础31[常用模块介绍]
- 常用的python模块
- Python 中的常用数据库接口模块
- Python常用模块种类的系统介绍及与操作系统相关的调用和操作
- Python常用模块种类的系统介绍及与操作系统相关的调用和操作
- python常用模块
- 常用的python模块
- 我接触到的常用python模块
- Python常用模块种类的系统介绍及与操作系统相关的调用和操作
- Python常用模块I与操作系统相关的调用和操作
- Python常用模块资料
- python的常用模块