小编Chi*_*moy的帖子

A*a =新A(); 这会创建指针还是对象?

A *a = new A();
Run Code Online (Sandbox Code Playgroud)

这会创建指针还是对象?

我是一名c ++初学者,所以我想了解这种差异.

c++

21
推荐指数
3
解决办法
1207
查看次数

如何设置QLineEdit换行

目前,我正在将文本复制到 LineEdit,然后单击 PushButton,它将把文本写入“data.txt”文件。我编写了一个readfile()将从 data.txt 读取文本的程序,然后单击 PushButton,它应该在 LineEdit 中以新行格式显示文本。这是我的代码:

    void MainWindow::writefile()
    {
        QString str = ui->lineEdit->text();
        QString filename = "data.txt";
        QFile file(filename);
        file.open(QIODevice::WriteOnly|QIODevice::Text);
        QTextStream out(&file);
        out<<str<<endl;
        file.close();
    }
    void MainWindow::readfile()
    {
        QString filename = "data.txt";
        QFile file(filename);
        file.open(QIODevice::ReadOnly|QIODevice::Text);
        QTextStream  in(&file);
        QString str = in.readLine();
        ui->lineEdit_2->setText(str);
        file.close();
    }
void MainWindow::on_pushButton_2_clicked()
{
    readfile();
}
void MainWindow::on_pushButton_clicked()
{
    writefile();
}
Run Code Online (Sandbox Code Playgroud)

请建议如何分隔这些逗号分隔的字符串,并且必须以换行格式显示

文件输入输出

c++ qt

4
推荐指数
1
解决办法
9834
查看次数

ValueError:使用 str.index 时未找到子字符串

我是 python 的初学者,我正在尝试以下代码

input_number = raw_input("Please input the number:")
print type(input_number)
if(input_number.index('0')):
    print "Not Accepted"
else:
    print "Accepted"
Run Code Online (Sandbox Code Playgroud)

当我给出输入时,例如“1234506”,它显示“未接受”,这是有效的,但是当我给出“123456”时,它的抛出错误“未找到子字符串”。那么我如何打印 else 部分。

python string indexing

3
推荐指数
2
解决办法
8611
查看次数

无法理解Perl哈希排序的行为

我是Perl的初学者,我试图从"Beginning Perl:Curtis Poe"运行这个示例

#!/perl/bin/perl

use strict;
use warnings;
use diagnostics;

my $hero = 'Ovid';
my $fool = $hero;
print "$hero isn't that much of a hero. $fool is a fool.\n";

$hero = 'anybody else';
print "$hero is probably more of a hero than $fool.\n";

my %snacks = (
    stinky   => 'limburger',
    yummy    => 'brie',
    surprise => 'soap slices',
);
my @cheese_tray = values %snacks;
print "Our cheese tray will have: ";
for my $cheese (@cheese_tray) {
    print "'$cheese' ";
} …
Run Code Online (Sandbox Code Playgroud)

perl perl-data-structures

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

标签 统计

c++ ×2

indexing ×1

perl ×1

perl-data-structures ×1

python ×1

qt ×1

string ×1