string中的通配format

本文详细介绍了如何使用Wiktionary API获取词汇定义,并通过字符串格式化展示API请求URL。示例代码清晰展示了参数设置及API调用过程。

private static final String WIKTIONARY_PAGE =
         "http://en.wiktionary.org/w/api.php?action=query&prop=revisions&titles=%s&" +
         "rvprop=content&format=json%s";


String aa = String.format(WIKTIONARY_PAGE, "===cc===", "===cc===");
 

  输出:

 

    http://en.wiktionary.org/w/api.php?action=query&prop=revisions&titles====cc===&rvprop=content&format=json===cc===

 
In file included from ./spdlog/v1.9.2/include/spdlog/fmt/fmt.h:24:0, from ./spdlog/v1.9.2/include/spdlog/common.h:45, from ./spdlog/v1.9.2/include/spdlog/spdlog.h:12, from ./loglib/cclog.h:8, from ./loglib/ccdeclare.h:7, from source/subtitdspi.h:8, from source/user.h:4, from source/user_prog.cpp:1: ./spdlog/v1.9.2/include/spdlog/fmt/bundled/core.h:344:30: 错误:‘enable_if_t’未声明 # define FMT_ENABLE_IF(...) enable_if_t<(__VA_ARGS__), int> = 0 ^ ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:433:31: 附注:in expansion of macro ‘FMT_ENABLE_IF’ template <typename Container, FMT_ENABLE_IF(is_contiguous<Container>::value)> ^ ./spdlog/v1.9.2/include/spdlog/fmt/bundled/core.h:344:41: 错误:expected ‘>’ before ‘<’ token # define FMT_ENABLE_IF(...) enable_if_t<(__VA_ARGS__), int> = 0 ^ ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:433:31: 附注:in expansion of macro ‘FMT_ENABLE_IF’ template <typename Container, FMT_ENABLE_IF(is_contiguous<Container>::value)> ^ In file included from ./spdlog/v1.9.2/include/spdlog/fmt/bundled/core.h:3234:0, from ./spdlog/v1.9.2/include/spdlog/fmt/fmt.h:24, from ./spdlog/v1.9.2/include/spdlog/common.h:45, from ./spdlog/v1.9.2/include/spdlog/spdlog.h:12, from ./loglib/cclog.h:8, from ./loglib/ccdeclare.h:7, from source/subtitdspi.h:8, from source/user.h:4, from source/user_prog.cpp:1: ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:435:27: 错误:‘checked_ptr’未声明 checked_ptr<typename Container::value_type>) ^ ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:435:38: 错误:expected ‘,’ or ‘...’ before ‘<’ token checked_ptr<typename Container::value_type>) ^ ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:436:13: 错误:ISO C++ 不允许声明无类型的‘base_iterator’ [-fpermissive] -> std::back_insert_iterator<Container> { ^ ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:436:13: 错误:在文件层将‘base_iterator’声明为‘auto’ ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:436:13: 错误:trailing return type only available with -std=c++11 or -std=gnu++11 ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:441:1: 错误:‘constexpr’不是一个类型名 constexpr auto base_iterator(Iterator, Iterator it) -> Iterator { ^ ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:441:1: 附注:C++11 ‘constexpr’ only available with -std=c++11 or -std=gnu++11 ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:449:8: 错误:ISO C++ 不允许声明无类型的‘fill_n’ [-fpermissive] -> OutputIt { ^ ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:449:8: 错误:在文件层将‘fill_n’声明为‘auto’ ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:449:8: 错误:trailing return type only available with -std=c++11 or -std=gnu++11 ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:454:65: 错误:ISO C++ 不允许声明无类型的‘fill_n’ [-fpermissive] FMT_CONSTEXPR20 auto fill_n(T* out, Size count, char value) -> T* { ^ ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:454:65: 错误:在文件层将‘fill_n’声明为‘auto’ ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:454:65: 错误:trailing return type only available with -std=c++11 or -std=gnu++11 ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:465:28: 警告:scoped enums only available with -std=c++11 or -std=gnu++11 [默认启用] enum char8_type : unsigned char {}; ^ ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:470:68: 错误:ISO C++ 不允许声明无类型的‘copy_str_noinline’ [-fpermissive] OutputIt out) -> OutputIt { ^ ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:470:68: 错误:在文件层将‘copy_str_noinline’声明为‘auto’ ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:470:68: 错误:trailing return type only available with -std=c++11 or -std=gnu++11 ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:492:18: 错误:ISO C++ 不允许声明无类型的‘utf8_decode’ [-fpermissive] -> const char* { ^ ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:492:18: 错误:在文件层将‘utf8_decode’声明为‘auto’ ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:492:18: 错误:trailing return type only available with -std=c++11 or -std=gnu++11 ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:523:1: 错误:‘constexpr’不是一个类型名 constexpr uint32_t invalid_code_point = ~uint32_t(); ^ ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:523:1: 附注:C++11 ‘constexpr’ only available with -std=c++11 or -std=gnu++11 ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:528:39: 错误:变量或字段‘for_each_codepoint’声明为 void FMT_CONSTEXPR void for_each_codepoint(string_view s, F f) { ^ ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:528:39: 错误:‘string_view’在此作用域中尚未声明 ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:528:56: 错误:expected primary-expression before ‘f’ FMT_CONSTEXPR void for_each_codepoint(string_view s, F f) { ^ ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:559:57: 错误:ISO C++ 不允许声明无类型的‘compute_width’ [-fpermissive] inline auto compute_width(basic_string_view<Char> s) -> size_t { ^ ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:559:57: 错误:在文件层将‘compute_width’声明为‘auto’ ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:559:57: 错误:trailing return type only available with -std=c++11 or -std=gnu++11 ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:564:43: 错误:‘fmt::v8::detail::compute_width’声明为‘inline’变量 FMT_CONSTEXPR inline size_t compute_width(string_view s) { ^ ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:564:43: 错误:‘string_view’在此作用域中尚未声明 ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:564:58: 错误:expected ‘,’ or ‘;’ before ‘{’ token FMT_CONSTEXPR inline size_t compute_width(string_view s) { ^ In file included from ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format.h:3099:0, from ./spdlog/v1.9.2/include/spdlog/fmt/bundled/core.h:3234, from ./spdlog/v1.9.2/include/spdlog/fmt/fmt.h:24, from ./spdlog/v1.9.2/include/spdlog/common.h:45, from ./spdlog/v1.9.2/include/spdlog/spdlog.h:12, from ./loglib/cclog.h:8, from ./loglib/ccdeclare.h:7, from source/subtitdspi.h:8, from source/user.h:4, from source/user_prog.cpp:1: ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format-inl.h:191:30: 错误:expected ‘}’ before end of line # pragma GCC diagnostic push ^ ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format-inl.h:191:30: 错误:expected ‘}’ before end of line ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format-inl.h:191:30: 错误:expected ‘}’ before end of line ./spdlog/v1.9.2/include/spdlog/fmt/bundled/format-inl.h:191:30: 错误:expected declaration before end of line make: *** [source/user_prog.o] 错误 1为什么会出现这个问题,我是在makefile所处目录下在终端输入make,然后出现的一系列错误,我的makefile文件如下所示:#获取.cpp文件 SrcFiles=$(wildcard source/*.cpp spdlog/*.cpp) #使用替换函数获取.o文件 ObjFiles=$(patsubst %.cpp,%.o,$(SrcFiles)) #生成的可执行文件 all:tiexample #目标文件依赖于.o文件 tiexample:$(ObjFiles) g++ -o $@ -I ../../lib -I ./spdlog/v1.9.2/include -I ./loglib -I ./source $(SrcFiles) -Wl,-rpath=../../lib -L ../../lib -l titdapi -lpthread #.o文件依赖于.cpp文件,使用,一条就够 %.o:%.cpp g++ -c -I ../../lib -I ./spdlog/v1.9.2/include -I ./loglib -I ./source $< rm *.o
最新发布
06-27
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值