小编fuu*_*man的帖子

一个 docker 卷中的多个文件夹

我有两个文件夹,比如说 /etc/folder1 和 /etc/folder2。我想将它们都映射到同一个 docker 卷中。这样我在卷的根目录中有这两个文件夹。那可能吗?

我想要的是:

/etc/folder1 
/etc/folder2
and then /vol1/folder1 and /vol1/folder2
Run Code Online (Sandbox Code Playgroud)

volume docker

5
推荐指数
2
解决办法
8013
查看次数

Python - 获取多部分电子邮件的正文

我收到一封包含以下代码的电子邮件:

m = imaplib.IMAP4_SSL(MailReceiveSRV)
m.login(MailReceiveUSER, MailReceivePWD)
m.select("Inbox")
status, unreadcount = m.status('INBOX', "(UNSEEN)")
unreadcount = int(unreadcount[0].split()[2].strip(').,]'))
items = m.search(None, "UNSEEN")
items = str(items[1]).strip('[\']').split(' ')
for index, emailid in enumerate(items):
    resp, data = m.fetch(emailid, "(RFC822)")
    email_body = data[0][1]
    mail = email.message_from_string(email_body)
    for part in mail.walk():
        body = part.get_payload()
Run Code Online (Sandbox Code Playgroud)

仅供参考:这始终是示例代码的一部分。

但身体现在是一个很大的对象列表。如果 Content_Type 是纯文本,那就容易多了。

我现在如何才能访问该邮件的正文?

python email multipart

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

Prolog - 比较两个数字

例如,我有一些代表数字 1 到 4 的原子。

喜欢

number(one).
number(two).
number(three).
number(four).
Run Code Online (Sandbox Code Playgroud)

现在我必须编写一个谓词来检查第一个数字是否大于第二个数字。

istBiggerThen(X,Y) :-
    (  X < Y
       -> true
       ;  false
    ).
Run Code Online (Sandbox Code Playgroud)

但现在我只能问诸如此类

isBiggerThan(3,4).
Run Code Online (Sandbox Code Playgroud)

但是我要

isBiggerThan(three,four).
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?请帮助我:) 提前致谢。

prolog

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

Haskell - 就像每个循环一样

我有三个列表.让我们说[a,b,c],[d,e]和[f,g,h]现在我想生成所有可能性.结果始终是以下语法:list1 + elem list2 + elem list3中的元素

例如:adf aeg cdf bdf bdg

等等.

我现在不知道.我想使用类似for-each-loop的东西,但它在haskell中没有用^^你有一些tipps来解决这个问题吗?

谢谢!

haskell for-loop

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

哈斯克尔 - 也许是其中之一

-- | Convert a 'Maybe a' to an equivalent 'Either () a'. Should be inverse
-- to 'eitherUnitToMaybe'.
maybeToEitherUnit :: Maybe a -> Either () a
maybeToEitherUnit a = error "Not yet implemented: maybeToEitherUnit"

-- | Convert a 'Either () a' to an equivalent 'Maybe a'. Should be inverse
-- to 'maybeToEitherUnit'.
eitherUnitToMaybe :: Either () a -> Maybe a
eitherUnitToMaybe = error "Not yet implemented: eitherUnitToMaybe"

-- | Convert a pair of a 'Bool' and an 'a' to 'Either …
Run Code Online (Sandbox Code Playgroud)

haskell either

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

哈斯克尔 - 地图a()

这条线做什么?

Map a ()
Run Code Online (Sandbox Code Playgroud)

我认为"map"是一个适用于列表的函数.

例如:

map (+1) [1,2,3] == [2,3,4]
Run Code Online (Sandbox Code Playgroud)

但那就像

map :: (a->b) -> [a] -> [b] 
map f xs 
Run Code Online (Sandbox Code Playgroud)

但是做什么呢

map a () 
Run Code Online (Sandbox Code Playgroud)

意思?我的意思是,()没有列表.从来没见过这个.

haskell map

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

Haskell - 写一个小解析器

我想为足球比分写一点解析器.

例如,"0:2"应该将输入解析为Just (Score 0 2).如果有类似的"3:3"东西应该给我"Nothing".其他一切也应该给我"Nothing".

data Score = Score Int Int
deriving (Eq,Show,Ord)


runParsec :: Parser a -> String -> Maybe a
runParsec parser input = case runP parser () "" input of
Left  _ -> Nothing
Right a -> Just a
Run Code Online (Sandbox Code Playgroud)

我将runParsec作为参数提供的解析器直到现在看起来像这样:

parseScore :: Parser Score
parseScore str1 = case str1 of
    "x:y" && (x /= y)   -> Right Score x y
    Otherwise           -> Left x
Run Code Online (Sandbox Code Playgroud)

我知道,parseScore的这段代码无法正常工作.因为我无法模式匹配像"x:y"这样的字符串.但是我该如何解决这个问题呢?

runParsec parseScore …

parsing haskell

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

标签 统计

haskell ×4

docker ×1

either ×1

email ×1

for-loop ×1

map ×1

multipart ×1

parsing ×1

prolog ×1

python ×1

volume ×1