好的,我正在尝试使用 py2app 为我的项目生成发行版。我仍然不确定我是否掌握了它的窍门。所以我的 setup.py 看起来像这样:
"""
This is a setup.py script generated by py2applet
Usage:
python setup.py py2app
"""
from setuptools import setup
import setuptools
PACKAGES = ['sqlalchemy.dialects.sqlite']
MODULES = ['sqlite3']
APP = ['tvb/interfaces/web/run.py']
OPTIONS = {'argv_emulation': True,
'packages': PACKAGES ,
'includes' : MODULES }
DATA_FILES = []
setup(
app=APP,
data_files=DATA_FILES,
packages = setuptools.find_packages(),
include_package_data=True,
options={'py2app': OPTIONS},
setup_requires=['py2app', "pyopengl", "cherrypy", "sqlalchemy", "simplejson",
"formencode", "genshi", "quantities","numpy", "scipy",
"numexpr", "nibabel", "cfflib", "mdp", "apscheduler",
"scikits.learn"]
)
Run Code Online (Sandbox Code Playgroud)
所以我的第一个问题是:我应该在 py2app 的模块中包含什么?py2app 是否知道扫描 setup_requires 中的内容并包含它们,或者我是否需要在 MODULES …
Unable to generate a temporary class (result=1). error CS2001: Source
file 'C:\Windows\TEMP\h3ugizgc.0.cs' could not be found error CS2008:
No inputs specified
error line
MemoryStream stream = new MemoryStream(System.Text.Encoding.Default.GetBytes(xmlSettings));
Line 52: XmlSerializer serializer = new XmlSerializer(typeof(Items));
Line 53: items = (Items)serializer.Deserialize(stream);
Run Code Online (Sandbox Code Playgroud)
当我尝试在Windows 7上使用IIS浏览我的应用程序时收到此错误消息.
我有一个简单的make文件,我想将当前日期和时间插入它创建的可执行文件中.
类似于:NOW=$(date +"%c")
附加到exe名称.最好的方法是什么?
谢谢!
我有一个函数,我想使用泛型返回CreditSupplementTradeline或CreditTradeline.问题是,如果我创建一个T ctl = new T(); ...我无法对ctl进行操作,因为VS2010无法识别其任何属性.可以这样做吗?谢谢.
internal T GetCreditTradeLine<T>(XElement liability, string creditReportID) where T: new()
{
T ctl = new T();
ctl.CreditorName = this.GetAttributeValue(liability.Element("_CREDITOR"), "_Name");
ctl.CreditLiabilityID = this.GetAttributeValue(liability, "CreditLiabilityID");
ctl.BorrowerID = this.GetAttributeValue(liability, "BorrowerID");
return ctl;
}
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
错误8'T'不包含'CreditorName'的定义,并且没有可以找到接受类型'T'的第一个参数的扩展方法'CreditorName'(您是否缺少using指令或程序集引用?)
我尝试在 C# 中使用正则表达式来匹配可以包含以下内容的软件版本号:
一些例子:
10.1.23.26812 83.33.7.5 10.1.23.26812[d] 83.33.7.5[q]
无效示例:
10.1.23.26812[ 83.33.7.5] 10.1.23.26812[d 83.33.7.5q
我已经尝试过以下方法:
string rex = @"[0-9][0-9][.][1-9]([0-9])?[.][1-9]([0-9])?[.][1-9]([0-9])?([0-9])?([0-9])?([0-9])?([[][a-zA-Z][]])?";
Run Code Online (Sandbox Code Playgroud)
(注意:如果我尝试不使用“@”并通过执行“\[”来转义方括号,则会收到错误消息“无法识别的转义序列”)
我可以达到版本号正确验证的程度,但它接受后面的任何内容(例如:“10.1.23.26812thisShouldBeWrong”被匹配为正确)。
所以我的问题是:有没有一种方法可以使用正则表达式来匹配/检查字符串中的方括号,或者我是否需要将其转换为不同的字符(例如:将 [a] 更改为 a并匹配 *s )?
NumPy的新手可能没有正确搜索,所以如果这是一个常见问题,我会采取肿块...
我正在研究一个问题,我需要计算相对较大数字的log(n!) - 即.为了大计算阶乘,所以我写了以下函数:
def log_fact(n):
x = 0
for i in range(1,n+1):
x += log(i)
return x
Run Code Online (Sandbox Code Playgroud)
现在问题是我想将此作为传递给curve_fit的函数的一部分:
def logfactfunc(x, a, b, c):
return a*log_fact(x) + b*x + c
from scipy.optimize import curve_fit
curve_fit(logfactfunc, x, y)
Run Code Online (Sandbox Code Playgroud)
但是,这会产生以下错误:
File "./fit2.py", line 16, in log_fact
for i in range(1,n+1):
TypeError: only length-1 arrays can be converted to Python scalars
Run Code Online (Sandbox Code Playgroud)
一点点搜索建议numpy.frompyfunc()将其转换为ufunc
curve_fit(np.frompyfunc(logfactfunc, 1, 1), data[k].step, data[k].sieve)
TypeError: <ufunc 'logfactfunc (vectorized)'> is not a Python function
Run Code Online (Sandbox Code Playgroud)
试过这个:
def logfactfunc(x, a, b, c):
return …
Run Code Online (Sandbox Code Playgroud) 有没有简单的方法来删除列表中的条目?我想只删除第一个条目.在我看过的每个论坛中,我可以删除一个条目的唯一方法就是使用该list.remove()
功能.这将是完美的,但我只能删除该条目,如果我知道它的名称.
list = ['hey', 'hi', 'hello', 'phil', 'zed', 'alpha']
list.remove(0)
Run Code Online (Sandbox Code Playgroud)
这不起作用,因为您只能根据其名称删除条目.我必须跑list.remove('hey')
.在这个特定的例子中我无法做到这一点.
如果您需要任何其他信息,请询问.
我正在解析我的vcard信息(复制到txt文件)以提取name:number
并将其放入字典中.
数据样本:
BEGIN:VCARD VERSION:2.1 N:MEO;Apoio;;; FN:Apoio MEO TEL;CELL;PREF:1696 TEL;CELL:162 00 END:VCARD BEGIN:VCARD VERSION:2.1 N:estrangeiro;Apoio MEO;no;; FN:Apoio MEO no estrangeiro TEL;CELL;PREF:+35196169000 END:VCARD
import re
file = open('Contacts.txt', 'r')
contacts = dict()
for line in file:
name = re.findall('FN:(.*)', line)
nm = ''.join(name)
if len(nm) == 0:
continue
contacts[nm] = contacts.get(nm)
print(contacts)
Run Code Online (Sandbox Code Playgroud)
有了这个,我得到一个带有名字的字典,但是对于数字,我得到的是无.{'name': None, 'name': None}
.
我可以这样做吗?使用相同的re.findall
表达式提取名称和数字?
我有一个从textviews构建的列表视图.
如果用户单击项目列表,则单击项目的文本将被更改,我该怎么做?
我知道如何添加新项目,但更改其文本?我怎样才能做到这一点?
当我尝试检查浮点变量是否包含完全整数值时,我得到了下面的奇怪行为.我的代码:
x = 1.7 print x, (x == int(x))
x += 0.1 print x, (x == int(x))
x += 0.1 print x, (x == int(x))
x += 0.1 print x, (x == int(x))
print "----------------------"
x = **2.7** print x, (x == int(x))
x += 0.1 print x, (x == int(x))
x += 0.1 print x, (x == int(x))
x += 0.1 print x, (x == int(x))
Run Code Online (Sandbox Code Playgroud)
我得到了下面的奇怪输出(最后一行是问题):
1.7 False
1.8 False
1.9 False
2.0 True
----------------------
2.7 False
2.8 …
Run Code Online (Sandbox Code Playgroud)