有一个 Django 应用程序“my_app”。现在添加了一个恰好具有相同名称的外部库,需要添加到 INSTALLED_APPS 中。
src
|
-- apps
|
--- **my_app**
external libraries
|
__ **my_app**
|
__some_path
|
__ new_module
Run Code Online (Sandbox Code Playgroud)
Django 走老路,吐了
Error: No module named my_app.some_path.new_module
Run Code Online (Sandbox Code Playgroud)
因为它正在寻找错误的文件夹。
INSTALLED_APPS = (
...
apps.my_app
my_app.some_path.new_module
...
)
Run Code Online (Sandbox Code Playgroud)
注意:INSTALLED_APPS 中应用程序的顺序没有区别。从 INSTALLED_APS 中删除 apps.my_app 也没有什么区别。
当我尝试输入时
import my_app
Run Code Online (Sandbox Code Playgroud)
pycharm 自动建议 apps.my_app
有没有办法在不重命名其中一个应用程序的情况下解决此问题?
我需要在运行时获得准确的listView高度.
当我使用下面的代码时,每个listItem的高度不正确.
int totalHeight = 0;
for (int i = 0; i < listAdapter.getCount(); i++) {
View listItem = listAdapter.getView(i, null, listview);
listItem.measure(0, 0);
totalHeight += listItem.getMeasuredHeight();
}
params.height = totalHeight + listview.getDividerHeight()* (listAdapter.getCount() -1);
listview.setLayoutParams(params);
listview.requestLayout();
Run Code Online (Sandbox Code Playgroud)
当我使用getChild版本时,高度准确但总计数已关闭...
int total = 0;
for (int i = 0; i < listview.getChildCount(); i++) {
View childAt = listview.getChildAt(i);
if (childAt == null)
continue;
int childH = childAt.getMeasuredHeight();
total += childH;
}
int div = listview.getDividerHeight();
total += (div * (listAdapter.getCount() - 1)); …Run Code Online (Sandbox Code Playgroud) 当从许多子串创建一个字符串时,更多的pythonic - +或%?
big_string = string1 + string2 + ... + stringN
big_string = ''
for i in range(n):
big_string+=str(i)
Run Code Online (Sandbox Code Playgroud)
要么
big_string = "%s%s...%s" % (string1, string2, ... , stringN)
big_string = ''
for i in range(n):
big_string = "%s%s" % (big_string, str(i))
Run Code Online (Sandbox Code Playgroud)