我知道一般来说 python 只会为类、函数等创建新的作用域,但我对as
try/ except 块或上下文管理器中的语句感到困惑。在块内部分配的变量可以在块外部访问,这是有道理的,但是与as
则不然。
所以这失败了:
try:
raise RuntimeError()
except RuntimeError as error:
pass
print(repr(error))
Run Code Online (Sandbox Code Playgroud)
但这成功了:
try:
raise RuntimeError()
except RuntimeError as e:
error = e
print(repr(error))
Run Code Online (Sandbox Code Playgroud)
与 绑定的变量发生了什么as
,为什么正常的 python 作用域规则不适用?PEP表明它只是一个正常绑定的 python 变量,但情况似乎并非如此。
我刚刚开始使用Jenkins,似乎无法让它工作.我在我的存储库的根目录中创建了一个名为'Jenkinsfile'的文本文件,但是当我尝试构建时,我收到错误"'找不到'Jenkinsfile'不符合条件".这是完整的Jenkins输出:
Started by user Joshua Fishman [Thu Jul 20 11:44:10 EDT 2017]
Starting branch indexing...
git.exe rev-parse --is-inside-work-tree # timeout=10 Setting origin to C:\Users\JoshuaF\git\edgeMagic-nextgen
git.exe config remote.origin.url C:\Users\JoshuaF\git\edgeMagic-nextgen # timeout=10 Fetching origin...
Fetching upstream changes from origin
git.exe --version #timeout=10
git.exe fetch --tags --progress origin
+refs/heads/*:refs/remotes/origin/*
git.exe ls-remote --symref C:\Users\JoshuaF\git\edgeMagic-nextgen # timeout=10
git.exe rev-parse --is-inside-work-tree # timeout=10 Setting origin to C:\Users\JoshuaF\git\edgeMagic-nextgen
git.exe config remote.origin.url C:\Users\JoshuaF\git\edgeMagic-nextgen # timeout=10
Fetching & pruning origin...
Fetching upstream changes from origin
git.exe --version # timeout=10 …
Run Code Online (Sandbox Code Playgroud) Jenkins中的Git Checkout抛出错误“文件名太长”并失败,如下所示:
hudson.plugins.git.GitException:命令“ git.exe签出-f 2cea7d8eb9185899c01d2ffc86872f584da2e60c”返回了状态代码1:
stdout:
stderr:错误:无法创建文件edgemagic-nextgen-core / src / test / resources / dbunit_test_data / com / cybra / edgemagic / service / EmObjectServiceTest / data / testInstances_create_dataRequiresData.xml:文件名太长
我已将配置文件中的longpaths变量设置为'true',如此处建议的那样,对于Windows,git的文件名太长,以及https://sifaserdarozen.wordpress.com/2015/06/25/git-file-name-错误时间过长/,但没有帮助。
我还能做些什么吗?
我正在尝试使机器人的链接动画化,但没有成功。FuncAnimation永远不会调用动画函数-永远不会执行print语句。任何帮助将不胜感激。我的代码:
joints = np.array([robot_kinematics.getJoints(a[0]) for a in path])
# this is [5x9x3]
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
colors = 'brgymcwkk'
lines = [ax.plot([], [], [])[0] for i,c in enumerate(colors)]
pt = ax.plot([], [], [])[0]
def animate(i,lines,pts):
print ('called')
for j,line in enumerate(lines):
line.set_data(joints[i,j,0:2])
line.set_3d_properties(joints[i,j,2])
pts.set_data(joints[i,:,0:2])
pts.set_3d_properties(joints[i,:,2])
return lines,pts
a = animation.FuncAnimation(fig, animate, 25, fargs=(lines,pt),interval=50, blit=False)
plt.show()
Run Code Online (Sandbox Code Playgroud) 全新的 AWS。昨天我能够很好地通过 ssh 连接到我的 EC2 实例,但今天 SSH 挂起这个(详细)输出:
-> ssh -vvv -i "x.pem" ec2-user@ec2-x-x-x-x.us-east-2.compute.amazonaws.com
OpenSSH_7.2p2 Ubuntu-4ubuntu2.4, OpenSSL 1.0.2g 1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "ec2-x-x-x-x.us-east-2.compute.amazonaws.com" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to ec2-x-x-x-x.us-east-2.compute.amazonaws.com [18.191.133.22] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file x.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file x.pem-cert type -1
debug1: …
Run Code Online (Sandbox Code Playgroud)