Python3:TypeError:'模块'对象不可呼应

发布于 2025-02-09 13:38:16 字数 513 浏览 4 评论 0原文

我一直在尝试在Mac终端上运行一些Python,并且我遇到了以下错误:“ TypeError:'Module'对象不可呼应”

参考代码:

import re
import pathlib as Path
mypath = Path('users/pranav/Desktop/sir/samplenames.txt')

有人可以为我分解错误并解释我应该做什么。要解决吗?

我还尝试使用SYS对其进行修复,但是,在我什至可以通过它进行工作之前,我被返回了一个错误:attributeError:'list'对象没有属性'dirname'code

w/ sys:

import sys
print(sys.path.dirname())
import re
import pathlib as Path
mypath = Path('/users/pranav/Desktop/sir/samplenames.txt')

任何帮助都将不胜感激。

I keep trying to run a bit of python on mac terminal, and I'm hit with the following error: "TypeError: 'module' object is not callable"

Reference code:

import re
import pathlib as Path
mypath = Path('users/pranav/Desktop/sir/samplenames.txt')

Could someone break down the error for me and explain what I should do to fix it?

I also tried to fix it using sys, however, before I could even work through it I was returned an error stating: AttributeError: 'list' object has no attribute 'dirname'

Code w/ sys:

import sys
print(sys.path.dirname())
import re
import pathlib as Path
mypath = Path('/users/pranav/Desktop/sir/samplenames.txt')

Any help would be greatly appreciated

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别靠近我心 2025-02-16 13:38:17
from pathlib import Path

SCR_DIR = 'C:\\users\\pranav\\Desktop\\sir'

mypath = Path(SRC_DIR, "samplenames.txt")
from pathlib import Path

SCR_DIR = 'C:\\users\\pranav\\Desktop\\sir'

mypath = Path(SRC_DIR, "samplenames.txt")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文