我试图找出如何使用Google Books API按ISBN搜索图书.我需要编写一个搜索ISBN的程序,然后打印出标题,作者和版本.我试过使用,List volumesList = books.volumes.list("");但是不允许我按ISBN搜索,我没有看到获取所需信息的方法(当ISBN放入其中时没有结果).我现在拥有的是:
JsonFactory jsonFactory = new JacksonFactory();
final Books books = new Books(new NetHttpTransport(), jsonFactory);
List volumesList = books.volumes.list("9780262140874");
volumesList.setMaxResults((long) 2);
volumesList.setFilter("ebooks");
try
{
Volumes volumes = volumesList.execute();
for (Volume volume : volumes.getItems())
{
VolumeVolumeInfo volumeInfomation = volume.getVolumeInfo();
System.out.println("Title: " + volumeInfomation.getTitle());
System.out.println("Id: " + volume.getId());
System.out.println("Authors: " + volumeInfomation.getAuthors());
System.out.println("date published: " + volumeInfomation.getPublishedDate());
System.out.println();
}
} catch (Exception ex) {
// TODO Auto-generated catch block
System.out.println("didnt wrork "+ex.toString());
}
Run Code Online (Sandbox Code Playgroud)
如果有人有任何关于如何提高效率的建议让我知道.新守则:
String titleBook=""; …Run Code Online (Sandbox Code Playgroud) 我正在尝试从DoInBackground中的asynctask返回值,但调用get()方法会冻结我的UI.如何将代码重新编写为回调方法?:
public class GetUrlDataTask extends AsyncTask<String, Integer, String> {
String response;
HttpUtils util;
@Override
protected String doInBackground(String... params) {
try {
util = new HttpUtils(params[0]);
response = util.getContent();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return response;
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
}
Run Code Online (Sandbox Code Playgroud)
在我的活动中,我得到了结果 response = new GetUrlDataTask().execute("site").get;
如何读取R中不属于格式表的文件?
数据包含某些值的空白数据.空白需要有价值.
"关于"和"名称"是唯一永远存在的价值观.
例如,文本文件如下:
Name
Type
Color
About
Spiderman
Marvel
Red
Swings from webs
Superman
DC
Likes to fly around
Hulk
Marvel
Green
I told you not top make him mad.
Batman
Black
He is a good fighter and detective
Martian Manhunter
DC
He is from Mars
Deadpool
Black Red
Kinda Crazy
Run Code Online (Sandbox Code Playgroud)
第一个条目是标题.我想把它变成一个数据框
Name Type Color About
Spiderman Marvel Red Swings from webs
Superman DC Likes to fly around
Hulk Marvel Green I told you not top make him mad. …Run Code Online (Sandbox Code Playgroud) 我正在做一个夏季项目.从我学校的网站上获取课程信息.
我从这里开始:http : //www.uah.edu/cgi-bin/schedule.pl? file = fall2015.html&segment =收集课程部门.
然后我从像这样的页面中获取信息.我有我需要的东西过滤到如下列表:
[1] "91091 211 01 PRINC OF FINANCIAL ACCOUNTING 3.0 55 22 33 0 MW 12:45PM 02:05PM BAB 106 Rose-Green E"
[2] "91092 211 02 PRINC OF FINANCIAL ACCOUNTING 3.0 53 18 35 0 TR 09:35AM 10:55AM BAB 123 STAFF"
[3] "91093 211 03 PRINC OF FINANCIAL ACCOUNTING 3.0 48 29 19 0 TR 05:30PM 06:50PM BAB 220 Hoskins J"
[4] "91094 212 01 MANAGEMENT ACCOUNTING 3.0 55 33 22 …Run Code Online (Sandbox Code Playgroud) 所以我制作了一个应该进行霍夫曼编码的程序.将我的答案与正确答案进行比较时,并非所有答案都匹配.
我有
[("a","0"),("c","100"),("b","101"),("d","110"),("f","1110"),("e","1111")]
Run Code Online (Sandbox Code Playgroud)
正确的答案是
[('a',"0"),('b',"101"),('c',"100"),('d',"111"),('e',"1101"),('f',"1100")]
Run Code Online (Sandbox Code Playgroud)
然而我的方法给了我一点点改变.在分支30上,我使用0来到D而不是1.
所以这让我想知道,这两个答案都是正确的吗?毕竟他们都有相同的字符串长度.
如果我错了,有人可以解释原因吗?
如果有人想要它,我的代码是在下面的Haskell中编写的
mergHufffman::(String,Int) -> (String,Int) -> (String,Int)
mergHufffman x y = (fst x ++ fst y, snd x + snd y)
data HTree a = Leaf a | Branch (HTree a) (HTree a) deriving Show
treeHuff::[(String,Int)] -> HTree (String,Int)
treeHuff (x:[]) = Leaf x
treeHuff (x:y:[])
| snd x < snd y = Branch (Leaf x) (Leaf y)
| snd x > snd y = Branch (Leaf y) (Leaf x)
treeHuff (x:y:z:list) …Run Code Online (Sandbox Code Playgroud) 我有一个功能:
someFun :: Applicative f => f a -> b -> f c
someFun x y = …
Run Code Online (Sandbox Code Playgroud)
对于这个论点y我需要给someFun是"FB"那可以说我有值
someX :: Applicative f => f a
someY :: Applicative f => f b
Run Code Online (Sandbox Code Playgroud)
我试着这样做
LiftA (someFun someX) someY
Run Code Online (Sandbox Code Playgroud)
但这给了我 f (f c)
我需要结果 f c
我遇到了一个我不明白的错误问题
代码:
mergHufffman::(String,Int) -> (String,Int) -> (String,Int)
mergHufffman x y = (fst x ++ fst y, snd x + snd y)
data HTree a = Leaf a | Branch (HTree a) (HTree a) deriving Show
treeHuff::[(String,Int)] -> HTree
treeHuff (x:[]) = Leaf x
treeHuff (x:y:[])
| snd x < snd y = Branch Leaf x Leaf y
| snd x > snd y = Branch Leaf y Leaf x
treeHuff (x:y:z:list)
| snd x > snd merged = Branch …Run Code Online (Sandbox Code Playgroud) 我想要获得monad的支持.我认为与国家monad一起玩是个不错的做法.
使用CLaSH的UART Rx :
-- UART RX Logic
data RxReg
= RxReg
{ _rx_reg :: BitVector 8
, _rx_data :: BitVector 8
, _rx_sample_cnt :: Unsigned 4
, _rx_cnt :: Unsigned 4
, _rx_frame_err :: Bool
, _rx_over_run :: Bool
, _rx_empty :: Bool
, _rx_d1 :: Bit
, _rx_d2 :: Bit
, _rx_busy :: Bool
}
makeLenses ''RxReg
uartRX r@(RxReg {..}) rx_in uld_rx_data rx_enable = flip execState r $ do
-- Synchronise the async signal
rx_d1 .= …Run Code Online (Sandbox Code Playgroud) haskell ×4
r ×2
android ×1
api ×1
applicative ×1
clash ×1
google-books ×1
http ×1
huffman-code ×1
isbn ×1
java ×1
monads ×1
parsing ×1
record ×1
web-scraping ×1