static

Django项目中使用本地Bootstrap

蹲街弑〆低调 提交于 2020-01-10 13:41:31
如何在Django项目中使用下载的Bootstrap, 步骤如下: 1. 下载Bootstrap到本地,bootstrap下载地址: https://v3.bootcss.com/getting-started/#download 2. 在DJango项目的目录下面新建一个static目录,static目录需要于templates在同一级 将下载的bootstrap拷贝到static目录下面,如下图所示: 3.在settings.py文件中加入如下代码: # STATIC SETTINGS STATIC_URL = '/static/' # BASE_DIR 是项目的绝对地址 #STATIC_ROOT = os.path.join(BASE_DIR, 'collect_static') #以下不是必须的 STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), ) 4.在templates文件夹下面新建一个base.html, 新建一个blog文件夹,在blog文件夹新建一个页面 base.html代码如下: <!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE

牛客网java

梦想的初衷 提交于 2020-01-10 11:45:52
1:下列代码运行的结果是什么? public class P { public static int abc = 123; static{ System.out.println("P is init"); } } public class S extends P { static{ System.out.println("S is init"); } } public class Test { public static void main(String[] args) { System.out.println(S.abc); } } View Code 原因: 2:下面程序的运行结果是:( ) public static void main(String args[]) { Thread t = new Thread() { public void run() { pong(); } }; t.run(); System.out.print("ping"); } static void pong() { System.out.print("pong"); } View Code 解释:并不是多线程竞争问题,就是正常执行,t.run是调用的Thead类中的run()方法,t.start才是执行线程,所以这题就是执行普通run()方法,先输出pong,在输出ping。 来源:

What's the overhead of creating a SLF4J loggers in static vs. non-static contexts?

China☆狼群 提交于 2020-01-10 08:45:20
问题 I've always used the following pattern to construct (SLF4J) loggers: private static final Logger log = LoggerFactory.getLogger(MyClass.class); This has worked so far, but I was wondering about the static context at some point and the need to pass in the concrete class literal all the time instead of just using a non-static logger like private final Logger log = LoggerFactory.getLogger(getClass()); This has basically been asked (and answered) before here for LOG4J Should logger be private

Difference between Static variable declared in different scopes

萝らか妹 提交于 2020-01-10 04:10:07
问题 What is the difference between declaring static variable inside a block and outside a block in a file? Eg, here, what is difference between static variables a,b,c,d? Can we declare a static variable that is accessible from all files of a program? static int a; void getVol(..) { static int b; } int main() { static int c; while(condition) { static int d; .... } some code here; return 0; } 回答1: Ultimately, there is no difference. Ignoring (for the moment) static member functions, static means

Advantage of using static variables in Java

主宰稳场 提交于 2020-01-10 03:16:18
问题 Say I have two classes like this: class A{ private static Random random = new Random(); public A(){ // Do something. } public Integer methodGetsCalledQuiteOften(){ return random.nextInt(); } } class B{ private Random random; public A(){ random = new Random(); // Do something. } public Integer methodGetsCalledQuiteOften(){ return random.nextInt(); } } In a scenario where both of them get instantiated multiple times and both of these classes' instances' method methodGetsCalledQuiteOften gets

C#基础知识——函数学习1

末鹿安然 提交于 2020-01-09 23:33:20
我们在Main()函数中,调用Test()函数,我们把Main()函数称之为调用者,把 Test()函数称之为被调用者。 如果被调用者想要得到调用者的值: 1)、传递参数。 2)、使用静态字段来模拟全局变量。 如果调用者想要得到被调用者的值: 1)、返回值 不管是实参还是形参,都是在内存中开辟了空间的。 方法的功能一定要单一 方法中最忌讳的就是出现提示用户输入的字眼。 实例:计算闰年 static void Main ( string [ ] args ) { bool a = IsRun ( 2020 ) ; Console . WriteLine ( a ) ; Console . ReadKey ( ) ; } /// <summary> /// 计算闰年方法 /// </summary> /// <param name="year">输入年份</param> /// <returns>是否是闰年</returns> public static bool IsRun ( int year ) { bool b = ( year % 400 == 0 ) || ( year % 4 == 0 && year % 100 == 0 ) ; return b ; } out、ref、params out参数。 如果你在一个方法中,返回多个相同类型的值的时候,可以考虑返回一个数组。

方法

拥有回忆 提交于 2020-01-09 20:30:21
1、方法 入门知识 定义格式: public static void 方法名称(){ 方法体; } // 调用格式: 方法名() 注意事项: 方法的定义先后顺序无所谓 方法定义必须是挨着的, 不能一个方法里面有多个方法 方法再定义的时候没有被调用,只有在调用的时候才开始执行 例子 public class DemoMethod{ public static void main(String[] args){ PrintHelloWorld(); } public static void PrintHelloWorld(){ System.out.println("hello world"); } } 1.1、方法的完整格式 完整定义格式 修饰符 返回值类型 方法名称(参数类型,参数名称){ 方法体; return 值; } 修饰符:现阶段就是 public static 返回值类型:也就是方法最终的数据是什么类型的 方法名称:方法的名字,小驼峰命名 参数类型:传入的参数数据类型 参数名称:就是变量名称, 多个参数使用逗号隔开 方法体:代码 return 停止当前的方法,将值进行返回 返回值:方法执行的结果, 无返回值的时候则使用 void 注意: return后面的返回值, 必须和方法名前面的返回值类型, 保持对应 1、方法的三要素 返回值类型 方法名称 参数列表 2

Internal static variables in C, would you use them?

岁酱吖の 提交于 2020-01-09 08:40:45
问题 In C you can have external static variables that are viewable every where in the file, while internal static variables are only visible in the function but is persistent For example: #include <stdio.h> void foo_bar( void ) { static counter = 0; printf("counter is %d\n", counter); counter++; } int main( void ) { foo_bar(); foo_bar(); foo_bar(); return 0; } the output will be counter is 0 counter is 1 counter is 2 My question is why would you use an internal static variable? If you don't want

Java 8: Interface with static methods instead of static util class

自古美人都是妖i 提交于 2020-01-09 07:12:27
问题 What is best practice in Java 8 when I need a bunch of stateless utility methods. Is it right to have an interface that will not be implemented by anyone i.e. public interface Signatures and public interface Environments , or is it better to do it the old way - have public final class Signatures and public final class Environments with private constructors || enums? 回答1: The main purpose of interfaces is to provide a type and a vocabulary of operations (methods) on that type. They're useful