标准库-inspect

import inspect
import os

#basename求一长串路径中,最后一个路径的名字
binary = os.path.basename(inspect.stack()[-1][1])
print (binary)

binary1 = (inspect.stack())
print (binary1)

binary2 = (inspect.stack()[-1][1])
print (binary2)

binary3 = (inspect.stack()[-1][0])
print (binary3)

binary4 = (inspect.stack()[-1][1])
print (binary4)
my_inspect.py

[FrameInfo(frame=<frame object at 0x00000000004A9828>, filename='D:\\Users\\Administrator\\eclipse-workspace\\nlp\\my_classmethod\\my_inspect.py', lineno=7, function='<module>', code_context=['binary1 = (inspect.stack())\n'], index=0)]

D:\Users\Administrator\eclipse-workspace\nlp\my_classmethod\my_inspect.py

<frame object at 0x00000000004A9828>

D:\Users\Administrator\eclipse-workspace\nlp\my_classmethod\my_inspect.py
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是 Python 3.9 版本的标准库列表: - abc - aifc - argparse - array - ast - asyncio - asyncore - atexit - audioop - base64 - bdb - binascii - binhex - bisect - builtins - bz2 - cProfile - calendar - cgi - cgitb - chunk - cmath - cmd - code - codecs - codeop - collections - collections.abc - colorsys - compileall - concurrent - configparser - contextlib - contextvars - copy - copyreg - crypt - csv - ctypes - curses - dataclasses - datetime - dbm - decimal - difflib - dis - distutils - doctest - email - encodings - ensurepip - enum - errno - faulthandler - fcntl - filecmp - fileinput - fnmatch - formatter - fractions - ftplib - functools - gc - getopt - getpass - glob - grp - gzip - hashlib - heapq - hmac - html - http - hyperlinks - imaplib - imghdr - importlib - inspect - io - ipaddress - itertools - json - keyword - lib2to3 - linecache - locale - logging - lzma - mailbox - mailcap - marshal - math - mmap - modulefinder - msilib - multiprocessing - netrc - nis - nntplib - numbers - opcode - operator - optparse - os - os.path - parser - pathlib - pdb - pickle - pickletools - pipes - pkgutil - platform - plistlib - poplib - pprint - profile - pstats - pty - py_compile - queue - quopri - random - re - readline - reprlib - resource - rlcompleter - runpy - sched - secrets - select - selectors - shelve - shlex - shutil - signal - site - smtpd - smtplib - sndhdr - socket - socketserver - sqlite3 - ssl - stat - statistics - string - stringprep - struct - subprocess - sunau - symbol - symtable - sys - sysconfig - syslog - tabnanny - tarfile - telnetlib - tempfile - termios - test - textwrap - threading - time - timeit - tkinter - token - tokenize - traceback - tracemalloc - tty - turtle - types - typing - unicodedata - unittest - urllib - uu - uuid - venv - warnings - wave - weakref - webbrowser - winreg - winsound - wsgiref - xdrlib - xml - xmlrpc - zipapp - zipfile - zipimport - zlib

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值