小编Tom*_*83B的帖子

在Qt中创建/写入新文件

我正在尝试写入文件,如果该文件不存在则创建它.我在互联网上搜索过,没有什么对我有用.

我的代码看起来像这样:

QString filename="Data.txt";
QFile file( filename );
if ( file.open(QIODevice::ReadWrite) )
{
    QTextStream stream( &file );
    stream << "something" << endl;
}
Run Code Online (Sandbox Code Playgroud)

如果我在目录中创建一个名为Data的文本文件,它将保持为空.如果我不创建任何东西,它也不会创建文件.我不知道该怎么做,这不是我尝试创建/写入文件的第一种方式,而且没有一种方法可行.

谢谢你的回答.

c++ qt

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

无法安装scipy - 冻结"运行setup.py install for scipy"

我跑的时候

sudo pip install -U scipy
Run Code Online (Sandbox Code Playgroud)

它首先被下载然后继续显示

Running setup.py install for scipy
Run Code Online (Sandbox Code Playgroud)

但它冻结在那里.我尝试升级pip本身.工作得很好.我的点子版本是1.5.4

我得到的唯一错误是InsecurePlatforWarning.完整输出如下所示:

tom@tom-ThinkPad-Edge-E430:~$ sudo pip install -U scipy
The directory '/home/tom/.cache/pip/http' or its parent directory
is not owned by the current user and the cache has been disabled.
Please check the permissions and owner of that directory. If
executing pip with sudo, you may want sudo's -H flag.
The directory '/home/tom/.cache/pip' or its parent directory is not
owned by the current user and caching wheels has been disabled. …
Run Code Online (Sandbox Code Playgroud)

python pip scipy

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

由于ssl错误,无法在python 3.6中pip安装包

我正在使用远程服务器.当我尝试在我的虚拟环境中使用pip安装任何东西时,我收到一个错误:

(venv) [barta@bivoj program]$ pip install -r requirements.txt 
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting joblib==0.11 (from -r requirements.txt (line 1))
  Could not fetch URL https://pypi.python.org/simple/joblib/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping
Run Code Online (Sandbox Code Playgroud)

使用python 2.7一切正常.我可以自己解决这个问题(我没有root权限)或者我是否需要联系管理员?

首先,当我在我的主文件夹中安装python 3.6时,我遇到了这个问题.我想问题可能是因为它在我的主文件夹中,所以我要求干净安装python 3.6.

我考虑更改setup.py并再次安装在我的家中,正如Claudio所建议的那样:

由于ssl模块不可用,pip3安装在虚拟环境中,python3.6失败

但我没有找到任何openssl文件夹./ usr/bin中有openssl,但这不是目录.我搜索了ssl.h文件,但没有在任何地方找到它.

python ssl

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

写入文本文件而不覆盖它

我正在用C++进行重力的数值模拟,我想在每次计算一个步骤时备份我的结果.

但是,我现在这样做,程序总是覆盖文件.我想我总是可以通过将文本保存在不同的文件或变量中来解决问题,但我想知道是否有更简单的方法来打开文本文件以便我不会覆盖它.

我目前的"备份代码"如下所示:

fstream log;
log.open ("log.txt");
if (log.is_open())
{...
  ...
  log.close();
}
Run Code Online (Sandbox Code Playgroud)

c++ numerical textinput

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

标签 统计

c++ ×2

python ×2

numerical ×1

pip ×1

qt ×1

scipy ×1

ssl ×1

textinput ×1