我希望从我的列表中为每个项目循环打印同义词
// IF YOU NEED REPEATITION USE ARRAYLIST INSTEAD OF SET!!
import java.util.*;
public class Permutation {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
System.out.println("ENTER A STRING");
Set<String> se=find(in.nextLine());
System.out.println((se));
}
public static Set<String> find(String s)
{
Set<String> ss=new HashSet<String>();
if(s==null)
{
return null;
}
if(s.length()==0)
{
ss.add("");
}
else
{
char c=s.charAt(0);
String st=s.substring(1);
Set<String> qq=find(st);
for(String str:qq)
{
for(int i=0;i<=str.length();i++)
{
ss.add(comb(str,c,i));
}
}
}
return ss;
}
public static String comb(String s,char c,int i)
{
String start=s.substring(0,i);
String end=s.substring(i);
return start+c+end;
}
}
// IF YOU NEED REPEATITION USE ARRAYLIST INSTEAD OF SET!!
尝试了几种循环方法但没有成功,请帮忙
手动打印1个命令
myList = ["First", "Second", "Third"]
response.body &lt; ===这将打印word&#34的同义词;第一个&#34;
如何循环打印我的列表中所有单词的正文? 感谢
答案 0 :(得分:0)
试试这个
for word in myList
response = unirest.get("https://wordsapiv1.p.mashape.com/words/" + word + "/synonyms", headers={ "X-Mashape-Key": "API_KEY", "Accept": "application/json" } )
print response.body
我不懂Python,但从它的文档来看,它似乎应该有用。