草庐IT

Hotel_Name

全部标签

python - 如何在多个模块中使用 logging.getLogger(__name__)

来自logginghowto对于Python2.7(我的重点):Agoodconventiontousewhennamingloggersistouseamodule-levellogger,ineachmodulewhichuseslogging,namedasfollows:logger=logging.getLogger(__name__)Thismeansthatloggernamestrackthepackage/modulehierarchy,andit’sintuitivelyobviouswhereeventsareloggedjustfromtheloggername

python - 导入错误 : cannot import name 'QStringList' in PyQt5

我正在使用PyQt5但无法导入QStringList。我知道QStringList曾经在PyQt4的模块QtCore中。所以我尝试使用导入类fromPyQt5.QtCoreimportQStringList但是它显示这个错误C:\Python34\python.exeC:/Users/User/PycharmProjects/FirstProject/Test.pyTraceback(mostrecentcalllast):File"C:/Users/User/PycharmProjects/FirstProject/Test.py",line3,infromPyQt5.QtCorei

python - "NameError: name ' ' is not defined"用户在 Python 中输入后

这个问题在这里已经有了答案:input()error-NameError:name'...'isnotdefined(15个答案)关闭7年前。我完全不知道为什么这不起作用。应该可以精确工作,对吧?UserName=input("Pleaseenteryourname:")print("HelloMr."+UserName)raw_input("")我得到这个异常:Traceback(mostrecentcalllast):File"Test1.py",line1,inUserName=input("Pleaseenteryourname:")File"",line1,inNameErr

python - 名称错误 : name 're' is not defined

这个问题在这里已经有了答案:NameError:name'datetime'isnotdefined(2个答案)关闭4年前。我是python的新手。很新。我从教程中复制了以下内容#!/usr/bin/pythonfromurllibimporturlopenfromBeautifulSoupimportBeautifulSoupwebpage=urlopen('http://feeds.huffingtonpost.com/huffingtonpost/LatestNews').readpatFinderTitle=re.compile('(.*)')patFinderLink=re.

python - 名称错误 : name 'exit' is not defined

我使用cxfreeze从planrequest.py创建了一个Windows可执行文件。它似乎工作正常,但是当我运行exe文件时,我得到NameError:name'exit'isnotdefinednameexitisnotdefinedinpython说明修复方法是使用importsys。但是,我使用importsys.该代码作为python脚本运行良好(例如,我在编译为可执行文件之前广泛测试了命令行参数。)importsocketimportsysiflen(sys.argv)==1:print("Usage:")print("PlanRequest[RequestString]

Python 自省(introspection) : access function name and docstring inside function definition

考虑以下python代码:deffunction():"Docstring"name=???doc=???returnname,doc>>>function()"function","Docstring"我需要用什么来替换问号,以便从同一函数中获取函数的名称和文档字符串?编辑:到目前为止,大多数答案都明确地将函数名称硬编码在其定义中。是否可以执行类似下面的操作,其中新函数get_name_doc将从调用它的外部框架访问该函数,并返回其名称和文档?defget_name_doc():???deffunction():"Docstring"name,doc=get_name_doc()re

python - 从 django.db 导入模型,迁移 ImportError : cannot import name migrations

所以我开始在我的Django网络服务器上遇到一些关于south的问题。迁移命令每次都失败并显示此输出:fromdjango.dbimportmodels,migrationsImportError:cannotimportnamemigrations(上面的错误显示了迁移失败文件的路径)我的django版本是1.5.1,而我的south版本是0.8.4最让我烦恼的是找不到模块django.db.migrations。有什么想法吗? 最佳答案 迁移是在Django1.7中引入的;您使用的是1.5。这是一个linktothedocsex

Python: "global name ' 时间'未定义”

我正在为一个打印“Wearetheknightswhosay'Ni'!”的friend用Python编写一个愚蠢的程序。然后休眠3秒,然后打印“Ni!”使用random模块的uniform()方法以随机间隔执行二十次。这是我的代码:fromtimeimportsleepimportrandomdefknights_of_ni():generator=random.Random()print"Wearetheknightswhosay'ni'."sleep(3)foriinrange(0,20):print"Ni!"sleep(generator.uniform(0,2))我尝试通过在解

python - BeautifulSoup: AttributeError: 'NavigableString' 对象没有属性 'name'

你知道为什么BeautifulSoup教程中的第一个例子http://www.crummy.com/software/BeautifulSoup/documentation.html#QuickStart给出AttributeError:'NavigableString'objecthasnoattribute'name'?根据thisanswerHTML中的空格字符会导致问题。我尝试使用几页的来源,并且1工作其他人给出了同样的错误(我删除了空格)。你能解释一下“name”指的是什么以及为什么会发生这个错误吗?谢谢。 最佳答案 na

python - 导入错误 : cannot import name MAXREPEAT with cx_Freeze

我在运行卡住的应用程序时遇到了cx_Freeze的问题(解冻后工作正常)。当运行该程序时,它会产生以下回溯:Traceback(mostrecentcalllast):File"/usr/local/lib/python2.7/site-packages/cx_Freeze/initscripts/Console.py",line27,inexeccodeinm.__dict__File"PythonApp/mainframe.py",line3,inFile"/usr/local/lib/python2.7/site-packages/dbus/__init__.py",line10