小编Kri*_*ass的帖子

Unicode显示问题(UnicodeEncodeError)通过"heroku run python"

如果我连接到Heroku worker dyno heroku run(例如,heroku run python用于交互式Python会话),任何通过此方式显示Unicode字符的尝试都会导致UnicodeEncodeError

本地:

$ python
Python 2.7.1 (r271:86832, Jun 25 2011, 05:09:01) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print u'\xa3'
£
Run Code Online (Sandbox Code Playgroud)

通过heroku run:

$ heroku run python
Running python attached to terminal... up, run.1
Python 2.7.2 (default, Oct 31 2011, 16:22:04) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for …
Run Code Online (Sandbox Code Playgroud)

python unicode heroku

2
推荐指数
1
解决办法
1284
查看次数

main()中的EXC_BAD_ACCESS

我有一个EXC_BAD_ACCESSmain(),这里是我的代码:

int main(int argc, char *argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    int retVal = UIApplicationMain(argc, argv, nil, @"TestBedAppDelegate");
    [pool release];
    return retVal;
}

@interface TestBedAppDelegate : NSObject <UIApplicationDelegate>
@end

@implementation TestBedAppDelegate
- (void)applicationDidFinishLaunching:(UIApplication *)application {    
    UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[[TestBedViewController alloc] init]];
    [window addSubview:nav.view];
    [window makeKeyAndVisible];
}
@end

- (void) action: (id) sender
{
    [self highRetainCount];
}

@implementation TestBedViewController
- (void) highRetainCount
{
    UIView …
Run Code Online (Sandbox Code Playgroud)

cocoa objective-c ios

2
推荐指数
1
解决办法
259
查看次数

通过遍历Go列表来查找项目

我正试图将一些C移植到Go.

我基本上在寻找类似于Haskell的东西 find :: (a -> Bool) -> [a] -> Maybe a

我(大致)这个C用于通过迭代查找"列表"中的项目:

struct foo {
    struct foo *next;
    char *name;
}

struct foo *foo_list;

// Snip

struct foo *foo = NULL;
for (f = foo_list; f; f = f->next) {
    if (!strcmp("bar", f->name) {
        foo = f;
    }
}

if (foo)
    // Stuff
Run Code Online (Sandbox Code Playgroud)

我怎么能在Go中很好地和惯用地做到这一点?

"名单"可能很小; 性能特征不是特别有趣.

我可能想要一个slice或一个listFoos或*Foos的"列表" ?

我目前有以下内容,但我怀疑它不是特别"惯用Go"!

var FooTable *list.List

// Snip

var foo *Foo = nil

for e …
Run Code Online (Sandbox Code Playgroud)

go

2
推荐指数
1
解决办法
83
查看次数

C 表达式必须是可修改的左值(我为什么要使用此表达式)

我有这个带有 ?: 运算符的表达式:

(adc.Voltage1[Counter.ADC_ConversionCount] = ADC_readResult(Handler.myAdc, ADC_ResultNumber_1))  > 10 ? Counter.WriteOut = 1 : Counter.WriteOut = 0;
Run Code Online (Sandbox Code Playgroud)

与 if-else 相同的表达式:

if((adc.Voltage1[Counter.ADC_ConversionCount] = ADC_readResult(Handler.myAdc, ADC_ResultNumber_1)) > 10 ){
    Counter.WriteOut = 1;
}else{
    Counter.WriteOut = 0;
}
Run Code Online (Sandbox Code Playgroud)

为什么在第一种情况下会出现“表达式必须是可修改的左值”错误?

ADC_readResult 函数返回类型是 uint_least16_t。这是 Counter 结构体定义和 ADC 结构体定义:

typedef struct __COUNTERS__ {
    uint16_t WriteOut;
    uint16_t ADC_ConversionCount;
    uint16_t ADC_CycleCount;
    uint8_t LimitADCReached1;
    uint8_t LimitADCReached2;
    uint8_t LimitADCReached3;
    uint8_t LimitADCReached4;
    uint8_t LimitADCReached5;
} COUNTERS;

typedef struct __ADC_VOLTAGES__ {
    uint16_t Voltage1[ADC_VAL];
    uint16_t Voltage2[ADC_VAL];
    uint16_t Voltage3[ADC_VAL];
    uint16_t Voltage4[ADC_VAL];
    uint16_t Voltage5[ADC_VAL];

} …
Run Code Online (Sandbox Code Playgroud)

c if-statement

2
推荐指数
1
解决办法
665
查看次数

变量中的If语句

我想根据某个变量以不同的方式打印同一页面的名称.

这是相应的代码.

$metaTitle ="'if($variable=='input'){ title#1 }else {  title#2 };'";
Run Code Online (Sandbox Code Playgroud)

生成的元标题最近在同一个文件中用于创建页面标题(<title></title>)

但它不断产生标题

if($variable=='input'){ title#1 }else {  title#2 };
Run Code Online (Sandbox Code Playgroud)

(整个if语句作为一个整体.它不识别if语句.它将语句视为纯文本.)

我在句子里做错了什么?

php variables if-statement

1
推荐指数
1
解决办法
3万
查看次数

nscfstring text无法识别的选择器发送到实例

我试图找出前3个小时的这个错误.通过搜索,我已经知道这个错误与内存管理有关,但我没有弄清楚我做错了什么.

我已经宣布了这4个标签:

@interface InteractiveHistory : UITableViewController {
UILabel *date;
UILabel *startTime;
UILabel *cal;
UILabel *duration;
}
Run Code Online (Sandbox Code Playgroud)

然后创建属性并合成它们.在viewDidLoad中,我初始化了所有这样的:

date = [[UILabel alloc] init];
Run Code Online (Sandbox Code Playgroud)

我也在dealloc()方法中释放它们.

我想要做的是使用这4个标签在表格的单元格中写入一些文本.文本将取决于indexPath.

在cellForRowAtIndexPath方法中,只显示2个标签并指示错误行:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];

        NSLog(@"constructing cell");

        //set up labels text

        date = [NSString stringWithFormat:@"%@",[[int_data objectAtIndex:indexPath.row] objectForKey:@"Date"]];


 NSLog(@"%@",date.text); //App crashes at this line
       [date setTag:1];


        startTime = [NSString stringWithFormat:@"%@",[[int_data objectAtIndex:indexPath.row] objectForKey:@"Start …
Run Code Online (Sandbox Code Playgroud)

memory-management objective-c ios4

0
推荐指数
1
解决办法
3631
查看次数

标签 统计

if-statement ×2

objective-c ×2

c ×1

cocoa ×1

go ×1

heroku ×1

ios ×1

ios4 ×1

memory-management ×1

php ×1

python ×1

unicode ×1

variables ×1