有人刚刚帮助我使用 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
我怎样才能捕获该副本?
试图让我的尝试除了阻止工作.
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)
我希望除了旅行