小编kRe*_*oSo的帖子

.zshenv或​​.zshrc中的PATH变量

我的设置是在linux linux中的zsh 5.0.5

我在.zshenv中设置了如下的PATH变量

typeset -U path
path=(~/bin $path)
DW=$HOME/Downloads
Run Code Online (Sandbox Code Playgroud)

但它不起作用.打印$ PATH仅显示

/usr/local/bin:/usr/bin:/usr/bin/vendor_perl:/usr/bin/core_perl
Run Code Online (Sandbox Code Playgroud)

.zshenv被读了,因为我可以看到设置了DW变量.仅设置了PATH变量.而我不明白的是,在将.zshenv重命名为.zshrc后,PATH变量才能正常工作.

在.zshenv中需要任何特殊处理设置环境变量吗?

zsh path

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

python 3中的字符编码转换

在 python 2.x 中,我使用了

"shift-jis".decode('shift-jis').encode('utf-8')
Run Code Online (Sandbox Code Playgroud)

但 python 3.x 中不再有 str.decode() 。python 3.x 中的等效代码是什么?

更新 :

更具体:

python2的函数是

def unzip(file, dir):
    zips = zipfile.ZipFile(file)
    for info in zips.infolist():
        info.filename = info.filename.decode('shift-jis').encode('utf-8')
        zips.extract(info,dir)

        print(info, filename)
Run Code Online (Sandbox Code Playgroud)

该函数的等效 python3 代码是什么?

python character-encoding python-3.x

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

嵌套 - 如果在Haskell中

我跟随现实世界的哈克尔,第2章有一个练习.

我的解决方案是

lastButOne xs = if null xs || null (tail xs)
                then []
                else if null (tail (tail xs))
                     then head xs
                     else lastButOne (tail xs)
Run Code Online (Sandbox Code Playgroud)

但除了[]之外它不起作用,并产生这样的错误.

*Main> lastButOne []
[]
*Main> lastButOne [1, 2]

<interactive>:5:13:
    No instance for (Num [a0]) arising from the literal `1'
    Possible fix: add an instance declaration for (Num [a0])
    In the expression: 1
    In the first argument of `lastButOne', namely `[1, 2]'
    In the expression: lastButOne [1, 2]
Run Code Online (Sandbox Code Playgroud)

我是一个相当新手,不明白这些神秘的错误信息.有任何想法吗?

haskell

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

标签 统计

character-encoding ×1

haskell ×1

path ×1

python ×1

python-3.x ×1

zsh ×1