小编sau*_*Dev的帖子

apache2使用python2.7&我想使用python3.4

我使用python bottle和mod_wsgi设置我的服务器我的瓶子脚本都是用python3.4编写的,但apache2服务器默认使用python2.7.6?

有没有办法让python3.4成为apache2上的默认python

我现在有货

python apache ubuntu mod-wsgi bottle

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

base64 Type Err,TypeError:expected bytes,not str

当我尝试这段代码时:

#!/usr/bin/python3.2

import time, sys, os
import base64
#####################
tmp = "/home/gh.txt"
ex = "/home/ex.txt"
if (len(sys.argv) < 2):
    print("enter name of the new dict and key")
else:
    global ns
    ns = sys.argv[1]
    global ps
    ps = sys.argv[2]

dss = "{<%s>:%s}" % (ns, ps)
os.system("touch dss0")
fi0 = open(tmp, "a")

fi0.write(dss)
d64i = base64.b64encode(tmp)
fi = open(ex, "a")
fi.write(d64i)
os.system("rm tmp")
Run Code Online (Sandbox Code Playgroud)

我知道这是错误:

File "./n64.py", line 19, in <module>
     d64i=base64.b64encode("/home/gh.txt")
File "/usr/lib/python3.2/base64.py", line 56, in b64encode
     raise TypeError("expected bytes, not %s" …
Run Code Online (Sandbox Code Playgroud)

python file-io base64 typeerror python-3.x

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

标签 统计

python ×2

apache ×1

base64 ×1

bottle ×1

file-io ×1

mod-wsgi ×1

python-3.x ×1

typeerror ×1

ubuntu ×1