小编Aar*_*ron的帖子

ostream_iterator 为字符串而不是 cout?

有人刚刚帮助我使用 boost 从目录中获取文件名

    if (exists(p))    // does p actually exist?
    {

        if (is_directory(p))      // is p a directory?
        {
            copy(directory_iterator(p), directory_iterator(), // directory_iterator::value_type
                ostream_iterator<directory_entry>(cout, "\n")); // is directory_entry, which is

        }
    }
Run Code Online (Sandbox Code Playgroud)

但我希望它是一个字符串而不是 cout

我怎样才能捕获该副本?

c++ boost cout copy

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

非常简单的python 3尝试除了ValueError而不是跳闸

试图让我的尝试除了阻止工作.

import sys

def main():
    try:
        test = int("hello")
    except ValueError:
        print("test")
        raise

main()
Run Code Online (Sandbox Code Playgroud)

输出是

C:\Python33>python.exe test.py
test
Traceback (most recent call last):
  File "test.py", line 10, in <module>
    main()
  File "test.py", line 5, in main
    test = int("hello")
ValueError: invalid literal for int() with base 10: 'hello'

C:\Python33>
Run Code Online (Sandbox Code Playgroud)

我希望除了旅行

python try-catch python-3.x

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

标签 统计

boost ×1

c++ ×1

copy ×1

cout ×1

python ×1

python-3.x ×1

try-catch ×1