Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django 使用特殊字符在Heroku(通过powershell)中设置环境变量_Django_Powershell_Heroku_Environment Variables - Fatal编程技术网

Django 使用特殊字符在Heroku(通过powershell)中设置环境变量

Django 使用特殊字符在Heroku(通过powershell)中设置环境变量,django,powershell,heroku,environment-variables,Django,Powershell,Heroku,Environment Variables,Django 1.8,Heroku,Powershell 我正在尝试为Heroku中的django密钥设置一个环境变量: (venv) PS WORKFOLDER> heroku config:set SECRET_KEY=eoik6-&dnr9elgmrt7-%3hu_&37$3hg!9c6x!^khjr3!z*z&b4 我收到这个错误消息(3次-因为我的字符串中有3个符号): 当我尝试建议的解决方案(在符号周围加上双引号)时: 我得到了这个错误: SECRET

Django 1.8,Heroku,Powershell

我正在尝试为Heroku中的django密钥设置一个环境变量:

(venv) PS WORKFOLDER> heroku config:set SECRET_KEY=eoik6-&dnr9elgmrt7-%3hu_&37$3hg!9c6x!^khjr3!z*z&b4
我收到这个错误消息(3次-因为我的字符串中有3个符号):

当我尝试建议的解决方案(在符号周围加上双引号)时:

我得到了这个错误:

SECRET_KEY: eoik6-
'dnr9elgmrt7-%3hu_' is not recognized as an internal or external command, operable program or batch file.
'37$3hg!9c6x!^khjr3!z*z' is not recognized as an internal or external command, operable program or batch file.
'b4' is not recognized as an internal or external command, operable program or batch file.

我还尝试了用斜杠转义,在整个字符串周围加引号,等等。同样的结果。那么如何设置我的环境变量呢?

我不熟悉Heroku,但是假设
Heroku
是可执行的,并且
config:set SECRET\u KEY=eo…
是命令行参数,您可以尝试以下操作:

&'heroku'@('config:set'、'SECRET_KEY=eoik6-“&'dnr9elgmrt7-%3hu_'、'37$3hg!9c6x!^khjr3!z*z'、'b4')

我刚刚尝试了一些方法,当您在整个值周围加上单引号(以及在符号周围加上双引号)时,效果很好:


可通过命令heroku config验证我刚刚试过。那也行!谢谢似乎我们的答案有重叠。@woodduck谢谢,PS在处理外部可执行文件和命令行参数时有些棘手,请参阅以了解此代码的工作原理。
(venv) PS WORKFOLDER> heroku config:set SECRET_KEY=eoik6-"&"dnr9elgmrt7-%3hu_"&"37$3hg!9c6x!^khjr3!z*z"&"b4
SECRET_KEY: eoik6-
'dnr9elgmrt7-%3hu_' is not recognized as an internal or external command, operable program or batch file.
'37$3hg!9c6x!^khjr3!z*z' is not recognized as an internal or external command, operable program or batch file.
'b4' is not recognized as an internal or external command, operable program or batch file.
heroku config:set SECRET_KEY='eoik6-"&"dnr9elgmrt7-%3hu_"&"37$3hg!9c6x!^khjr3!z*z"&"b4'