我正在研究一个用c ++编写的项目(我刚刚开始学习)并且无法理解为什么这个函数不起作用.我正在尝试使用变量first_name编写"Person"类,并使用函数set_first_name来设置名称.Set_first_name需要调用一个函数(下面的函数)来检查名称中是否有任何数字.该函数总是返回false,我想知道为什么?此外,这是检查数字的最佳方式,还是有更好的方法?
bool Person::contains_number(std::string c){ // checks if a string contains a number
if (c.find('0') == std::string::npos || c.find('1') == std::string::npos || c.find('2') == std::string::npos || c.find('3') == std::string::npos
|| c.find('4') == std::string::npos || c.find('5') == std::string::npos || c.find('6') == std::string::npos || c.find('7') == std::string::npos
|| c.find('8') == std::string::npos || c.find('9') == std::string::npos){// checks if it contains number
return false;
}
return true;
}
Run Code Online (Sandbox Code Playgroud) 当我尝试运行django时,这就是我得到的:
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python manage.py runserver 8000
Error: No module named psycopg2.extensions
Process finished with exit code 1
Run Code Online (Sandbox Code Playgroud)
我发现了其他有类似问题的问题,但是在mac上没有问题,没有解决方案有帮助.我没有得到任何其他错误,我安装了psycopg2.我在PyCharm工作.这是我的设置文件(或至少是它的顶部).
ADMINS = (
# ('Your Name', 'your_email@example.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '---', # Or path to database file if using sqlite3.
'USER': '---', # Not used with sqlite3.
'PASSWORD': '---', # Not used with sqlite3.
'HOST': 'www.-----.com', # Set to empty string for localhost. Not used with sqlite3. …Run Code Online (Sandbox Code Playgroud) Django的开发服务器非常奇怪.访问它的浏览器在加载时卡住了,任何退出它的尝试都不起作用.当我打control c它似乎相当,但实际上仍然在运行.让它退出的唯一方法是重启我的电脑,这非常令人沮丧.有没有办法迫使它退出.我正在跑狮子山.有谁知道它运行的进程的名称被调用,所以我可以强制它从活动监视器退出.
django macos web-development-server activity-monitor osx-mountain-lion
我正在创建一个程序,可以在其他内容中淡入淡出音乐.问题是其他线程/队列可以暂停音乐,这意味着淡入和淡出也不仅需要暂停,还需要暂停.我需要能够在dispatch_after上暂停"定时器"(因为这是在音乐开始播放时调用,以便告诉它何时开始淡出,如果它被暂停则需要延迟)并暂停队列本身(为了暂停淡入或淡出,当它们淡入或淡出时)
这是代码(fadeIn和delayFadeOut都在程序开头调用):
- (void) doFadeIn: (float) incriment to: (int) volume with: (AVAudioPlayer*) thisplayer on: (dispatch_queue_t) queue{
dispatch_async(queue, ^{
double delayInSeconds = .1;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, queue, ^(void){
thisplayer.volume = (thisplayer.volume + incriment) < volume ? thisplayer.volume + incriment : volume;
NSLog([[[NSNumber alloc] initWithFloat:thisplayer.volume] stringValue]);
if (thisplayer.volume < volume) {
[self doFadeIn:incriment to:volume with:thisplayer on:queue];
}
});
});
}
-(void) doDelayFadeOut: (float) incriment with: (AVAudioPlayer*) thisplayer on: (dispatch_queue_t) queue
{
dispatch_async(queue, ^{
double delayInSeconds = .1; …Run Code Online (Sandbox Code Playgroud) 我有以下代码:
+(NSURL*) getRecordingDirectory {
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString* documentsDirectory = [paths objectAtIndex:0];
NSURL* url = [[NSURL alloc] initWithString:documentsDirectory]; //<-- nil
return url;
}
Run Code Online (Sandbox Code Playgroud)
这条线NSURL* url = [[NSURL alloc] initWithString:documentsDirectory];似乎不起作用.url留在线nil后.
Eclipse不允许我包含<iostream>.我在Mac上,当我使用xcode尝试相同的东西时,它可以工作.我正在运行eclipse Indigo,我已经尝试了MAc OS X编译器选项和跨平台选项.
在构建了boost库之后(所以我可以使用文件系统命名空间)我在stage/lib文件夹中找到了名称中带有filesystem的以下文件:
libboost_filesystem-vc100-mt-1_51 (838 kb)
libboost_filesystem-vc100-gd-mt-1_51 (4210 kb)
Run Code Online (Sandbox Code Playgroud)
注意第二个中的-gd.我还在括号中加上大小.那么,有什么区别?我用哪一个?
我有一个模板,其中包含以下内容:{% extends "main/main-template.html" %}
我还想要一个完全相同的模板,而不是它{% extends "main/main-template-quick.html" %}只是将相同的代码复制并粘贴到新文件中似乎违反DRY,这样我就可以更改模板了.有没有办法动态选择超级模板?
如果没有,是否有一个很好的方法来执行以下操作:使用{% block %}不同的模板重用相同的内容.同时,不要违反DRY.
我也对其他能够做到这一点的模板语言持开放态度.
我正在使用docx.js,它在浏览器中将 docx 转换为 html5。该函数convertContent输出一个NodeList. 问题是我需要一个 HTML/XML 字符串,而不是NodeList.
有什么方法可以将NodeListHTML 转换回来吗?有很多其他方式或将其转换为数组的示例,但没有关于如何将其转换回 HTML 的示例。
当我在浏览器中调用put或customPUT检查请求主体时,将发送原始对象,而不是更新的对象.我检查了该RestAngular对象{{ object }},它是被更新.
这是控制器(APIUsers是一个RestAngular服务):
$scope.objects = {};
(function waitForNgInit(fnct) {
$scope.$watch('userID', function(newVal) {
if (newVal !== undefined) {
fnct();
}
});
})(function retrieveUser() {
$scope.objects.user = APIUsers.one($scope.userID).get().$object;
});
$scope.saveSettings = function() {
$scope.objects.user.customPUT($scope.objects.user).then(function(resp) {
$scope.errors = [];
}, function(err) {
console.log(err.data);
$scope.errors = err.data.errors;
});
};
Run Code Online (Sandbox Code Playgroud)
这是Jade(HTML模板代码):
div.user-settings.form-section(ng-controller="userSettingsFormController")
{{ objects }}
ul.error-box(ng-show="errors != undefined && errors.legnth != 0")
li(ng-repeat="error in errors") {{ error.msg }}
.form-group
label(for="username") …Run Code Online (Sandbox Code Playgroud) django ×3
c++ ×2
cocoa-touch ×2
ios ×2
javascript ×2
macos ×2
python ×2
angularjs ×1
boost ×1
class ×1
database ×1
docx ×1
eclipse ×1
function ×1
html ×1
numbers ×1
objective-c ×1
postgresql ×1
psycopg2 ×1
rest ×1
restangular ×1