首页 > 编程语言 > 详细

05.Python学习笔记之-条件、循环和其他语句

时间:2020-06-14 11:16:42      阅读:54      评论:0      收藏:0      [点我收藏+]

一、import语句

在 python 用 import 或者 from...import 来导入相应的模块。

将整个模块(somemodule)导入,格式为: import somemodule

从某个模块中导入某个函数,格式为: from somemodule import somefunction

从某个模块中导入多个函数,格式为: from somemodule import firstfunc, secondfunc, thirdfunc

将某个模块中的全部函数导入,格式为: from somemodule import *

 

python的标准库地址:https://docs.python.org/zh-cn/3/library/index.html

第三方模块集合:https://pypi.org/

查询模块及模块里的函数使用方法

dir的作用:

shell提供在>>>提示窗口使用的两个交互式函数。dir会显示Python中与某个东西相关的所有属性,包括模块

help的作用:

请求相关模块中相关函数的帮主文档  help(os.kill)  就是请求os模块中kill函数的帮主文档

>>> dir(os)
[DirEntry, F_OK, MutableMapping, O_APPEND, O_BINARY, O_CREAT, O_EXCL, O_NOINHERIT, O_RANDOM, O_RDONLY, O_RDWR, O_SEQUENTIAL, O_SHORT_LIVED, O_TEMPORARY, O_TEXT, O_TRUNC, O_WRONLY, P_DETACH, P_NOWAIT, P_NOWAITO, P_OVERLAY, P_WAIT, PathLike, R_OK, SEEK_CUR, SEEK_END, SEEK_SET, TMP_MAX, W_OK, X_OK, _AddedDllDirectory, _Environ, __all__, __builtins__, __cached__, __doc__, __file__, __loader__, __name__, __package__, __spec__, _execvpe, _exists, _exit, _fspath, _get_exports_list, _putenv, _unsetenv, _wrap_close, abc, abort, access, add_dll_directory, altsep, chdir, chmod, close, closerange, cpu_count, curdir, defpath, device_encoding, devnull, dup, dup2, environ, error, execl, execle, execlp, execlpe, execv, execve, execvp, execvpe, extsep, fdopen, fsdecode, fsencode, fspath, fstat, fsync, ftruncate, get_exec_path, get_handle_inheritable, get_inheritable, get_terminal_size, getcwd, getcwdb, getenv, getlogin, getpid, getppid, isatty, kill, linesep, link, listdir, lseek, lstat, makedirs, mkdir, name, open, pardir, path, pathsep, pipe, popen, putenv, read, readlink, remove, removedirs, rename, renames, replace, rmdir, scandir, sep, set_handle_inheritable, set_inheritable, spawnl, spawnle, spawnv, spawnve, st, startfile, stat, stat_result, statvfs_result, strerror, supports_bytes_environ, supports_dir_fd, supports_effective_ids, supports_fd, supports_follow_symlinks, symlink, sys, system, terminal_size, times, times_result, truncate, umask, uname_result, unlink, urandom, utime, waitpid, walk, write]
>>> help(os.kill)
Help on built-in function kill in module nt:

kill(pid, signal, /)
    Kill a process with a signal.

 

技术分享图片

 

05.Python学习笔记之-条件、循环和其他语句

原文:https://www.cnblogs.com/shigozsr/p/13124089.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!