在过去的几个小时里,有一种常见的设计模式困在我的脑海中,它一直困扰着我,因为我不记得它的名字.
我不记得这个名字,但至少我可以形容它.
设计是在适当的时间加载库以减轻用户体验,因为他们不需要等待不必要的加载时间.它在启动程序时通常使用.
下面是python中的伪代码
main.py
#main.py
import platform
if platform.system() == "Darwin":
from QwertyMac import QwertyMac as Application
elif platform.system() == "Windows":
from QwertyWindows import QwertyWindows as Application
elif platform.system() == "Linux":
from QwertyLinux import QwertyLinux as Application
else:
print "platform is not supported"
exit()
app = Application()
app.run()
Run Code Online (Sandbox Code Playgroud)
QwertyMac.py
#QwertyMac.py
import sys, thread, time # and other 50++ libs.
Run Code Online (Sandbox Code Playgroud)
QwertyWindows.py
#QwertyWindows.py
import sys, thread, time # and other 50++ libs.
Run Code Online (Sandbox Code Playgroud)
QwertyLinux.py
#QwertyLinux.py
import sys, thread, time # and other …Run Code Online (Sandbox Code Playgroud) 你怎么做相反的
asd = 'qwe'
asd.match('qwe') do
p 'it matches'
else
p 'it doesnt match'
end
Run Code Online (Sandbox Code Playgroud)
反过来,我的意思是
asd.does_not_match('qwe') do
p 'it doesnt match'
else
p 'it matches'
end
Run Code Online (Sandbox Code Playgroud)
'不匹配'的语法是什么?
我有这个代码,它应该运行正常,但由于某种原因,循环将循环通过我在循环的条件检查之前释放字符串.从循环中退出的唯一方法是给出超过3位的整数(输入> 99 || input <-99).我正在使用gcc编译此代码,代码:: blocks作为IDE.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char* createString(void);
int main() {
int temp = 0;
char* string = 0;
char* error = 0;
do {
printf("\n Integer: ");
string = createString();
temp = strtol(string, &error, 10);
if (*error != '\n' && *error != '\0') printf("\n Input is not an integer");
free(string);
string = 0;
} while (*error != '\n' && *error != '\0');
free(error);
error = 0;
return 0;
}
char* createString() {
char* …Run Code Online (Sandbox Code Playgroud)